Actually, that comment points to the implementation of WriteString for the fmt package's internal pp type, which in turn is used by other fmt functions to handle strings efficiently. After scanning that source file some more, and the source file for io.WriteString ( https://golang.org/src/io/io.go?s=10163:10218#L279) I can see that even though fmt.Fprint and others don't use io.WriteString directly, they do exactly the same thing io.WriteString does, which is calling the destination's Write method exactly once and only once, thus avoiding extra allocations. So in conclusion, from what I see, it's equally efficient to write a string to a writer via io.WriteString or fmt.Fprint.
On Monday, April 22, 2019 at 9:28:50 AM UTC-4, Constantin Konstantinidis wrote: > > fmt.Fprint is calling io.WriteString as you can this comment > <https://github.com/golang/go/blob/68d4b1265ec7915dccfccf6c0e32f9ab2d9c3a86/src/fmt/print.go#L186> > > and the code around indicates. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.