debuggoModerate
How can I print to Stderr in Go without using log
Viewed 0 times
howstderrlogusingcanprintwithout
Problem
How can I write a message to Stderr without using
A comment in this SO post shows how to do it with
Is the following good Go?
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")Solution
The Go builtin functions
Documentation: https://golang.org/pkg/builtin/#print
print and println print to stderr. So if you simply want to output some text to stderr you can dopackage main
func main() {
println("Hello stderr!")
}Documentation: https://golang.org/pkg/builtin/#print
Code Snippets
package main
func main() {
println("Hello stderr!")
}Context
Stack Overflow Q#29721449, score: 39
Revisions (0)
No revisions yet.