How can I write a message to Stderr without using log
?
A comment in this SO post shows how to do it with log
: log.Println("Message")
, but what if I don't want a timestamp?
Is the following good Go?
os.Stderr.WriteString("Message")
How can I write a message to Stderr without using log
?
A comment in this SO post shows how to do it with log
: log.Println("Message")
, but what if I don't want a timestamp?
Is the following good Go?
os.Stderr.WriteString("Message")
If you don't want timestamps, just create a new log.Logger
with flag
set to 0
:
l := log.New(os.Stderr, "", 0)
l.Println("log msg")
EDIT:
Is the following good Go?
os.Stderr.WriteString("Message")
This is acceptable, and you can also use fmt.Fprintf
and friends to get formatted output:
fmt.Fprintf(os.Stderr, "number of foo: %d", nFoo)