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