fmt.Print and fmt.Println


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!

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


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:

Thank you @Zyl1 for simple example.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.