Is it safe for more than one goroutine to print to stdout?

No it’s not safe even though you may not sometimes observe any troubles. IIRC, the fmt package tries to be on the safe side, so probably intermixing of some sort may occur but no process crash, hopefully.

This is an instance of a more universal Go documentation rule: Things are not safe for concurrent access unless specified otherwise or where obvious from context.

One can have a safe version of a nice subset of fmt.Print* functionality using the log package with some small initial setup.

Leave a Comment