How do I print message to stderr in Go?

前端 未结 3 822
臣服心动
臣服心动 2021-01-04 06:50

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
<         


        
3条回答
  •  自闭症患者
    2021-01-04 07:07

    The log package by default prints to os.Stderr.

    You can also use os.Stderr directly (it's an os.File).

提交回复
热议问题