In Golang, how to print string to STDERR?

In Golang, the fmt.Println() is convenient to print to STDOUT. But how to print string to STDERR?

asked Aug 5, 2016 by anonymous

1 Answer

In Go os package, "Stdin, Stdout, and Stderr are open Files pointing to the standard input, standard output, and standard error file descriptors."

So, you can use the WriteString function on File on os.Stderr to print string to the STDERR. For example,

os.Stderr.WriteString("Msg to STDERR\n")
answered Oct 10, 2016 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Related questions

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...