英文:
Is there a way to see the programs stdout and stderr in delve debugger for golang?
问题
当使用delve调试Go程序时,我想要能够看到stdout和stderr的输出。这个有可能吗?我该如何做到这一点?
英文:
I'd like to be able to see the stdout and stderr when using delve to debug go programs. Is this possible? How would I do this?
答案1
得分: 1
你不需要做任何事情。
Delve默认将stdout和stderr打印到其控制台。我在MacOS ElCapitan上尝试过这个,使用的是Delve版本0.11.0-alpha。
在你的GOPATH的正确子目录中有一个main.go文件:
package main
import "fmt"
import "os"
func main() {
fmt.Fprintf(os.Stderr, "Writing something to stderr\n")
fmt.Fprintf(os.Stdout, "Writing something to stdout\n")
}
然后在与main.go相同的目录中运行Delve:
$ dlv debug
Type 'help' for list of commands.
(dlv) restart
Process restarted with PID 70964
(dlv) c
Writing something to stderr
Writing something to stdout
Process 70964 has exited with status 0
(dlv)
英文:
You do not need to do anything.
Delve by default prints the stdout and stderr to its console.
I have tried this in MacOS ElCapitan delve version 0.11.0-alpha
Have a main.go in the right subdir in your GOPATH
package main
import "fmt"
import "os"
func main() {
fmt.Fprintf(os.Stderr, "Writing something to stderr\n")
fmt.Fprintf(os.Stdout, "Writing something to stdout\n")
}
Then run the delve in the same dir as the main.go
$ dlv debug
Type 'help' for list of commands.
(dlv) restart
Process restarted with PID 70964
(dlv) c
Writing something to stderr
Writing something to stdout
Process 70964 has exited with status 0
(dlv)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论