如何在Go中将信息打印到stderr? [英] How to print message to stderr in Go?
本文介绍了如何在Go中将信息打印到stderr?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想打印一些日志以进行调试和测试,但以前的日志非常庞大,所以我应该将自己的日志打印到stderr中:
go run main.go 1> / dev / null
这样我就可以看到我自己的日志。
我应该怎么做?
谢谢 < log 软件包 log.go#L58>默认打印到 os.Stderr
。
您也可以使用直接 os.Stderr
(它是 os.File
)。
I want to print some logs for debugging and testing, but previous logs are massive, So I should print my own logs to stderr:
go run main.go 1>/dev/null
So that I can just see my own logs.
What should I do?
Thank you
解决方案
The log
package by default prints to os.Stderr
.
You can also use os.Stderr
directly (it's an os.File
).
这篇关于如何在Go中将信息打印到stderr?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文