kaitian521 kaitian521 - 1 year ago 93
Linux Question

How to print message to stderr in Go?

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

Answer Source

The log package by default prints to os.Stderr.

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download