Reputation: 49
I'm learning Go and one annoyance I have with it is when i use fmt.Println it adds a space after every argument passed (even variables). Is there a way to remove this space so it only adds a space if I add one in quotes?
Upvotes: 1
Views: 7044
Reputation: 11626
If you want something that works like println, where you don't have to put %v markers, then fmt.Print does the job.
it doesn't add spaces between arguments, and also doesn't add a newline.
for example:
fmt.Print("a","b","c","\n")
prints: abc
Upvotes: 2
Reputation: 49181
Use "Printf" function with format string instead.
fmt.Printf("string %s, integer %d, anything %v\n", "hello", 1, struct {}{})
Upvotes: 3