@drsensor Oh, "fun". This demonstrates: https://go.dev/play/p/NdoiBDbQuzn
TBH I never use Sprint with more than one argument, so I wasn't really aware either.
@drsensor @Merovius fmt.Sprint() and fmt.Sprintf() are very different beasts.
Only fmt.Sprint() does the "spaces" added thing. The idea being that if you go:
a := 1
b := 2
fmt.Sprint(a, b)
conveniently assumes you want to see:
1 2
rather than
12
If you go:
fmt.Sprint(a, " gt ", b)
Sprint() assumes you've considered spacing and prints:
1 gt 2
fmt.Sprint() is purely a convenience function which mostly "does what you want". If you don't like it, use the myriad prescriptive functions.
@drsensor @Merovius I see Sprint() as more of a diagnostic/debug output service.
a := 1
b := 2
Sprint(a, b)
is less keystrokes and less thinking than
Sprintf("%d %d", a, b)
as is:
Sprint(a, " < ", b)
vs
Sprintf("%d < %d", a, b)
In general, as a diagnostic print, you can just feed arguments to Sprint() and you'll get good output without worrying about formatting, e.g:
Sprint(int, string, []byte, float, struct)
just works.
So yeah, convenient. Just not a strict formatting tool.