fmt.Print and fmt.Println

(Martin “caubert” Kauber) #1


my first post in this very helpful forum, so I try to make sense : )

My problem is. I don’t understand why does Println generate two extra bytes of whitespace in this code >

Really puzzled and I don’t know how to search for the answer as well, so any guidance would be great!

Thank you guys!

(Norbert Melzer) #2

Because both functions work as documented. println always adds spaces, print only when at least one of the two neighbors is not a string.

(MMulthaupt) #3

Println joins the arguments with spaces, while Print does not. (well, not always) You don’t need such a verbose example to see the difference:

(Yujin Boby) #4

Thank you @Zyl1 for simple example.