Sorry for the basic question. I'd like to pass a slice as arguments to fmt.Sprintf
. Something like this:
values := []string{"foo", "bar", "baz"}
result := fmt.Sprintf("%s%s%s", values...)
And the result would be foobarbaz
, but this obviously doesn't work.
(the string I want to format is more complicated than that, so a simple concatenation won't do it :)
So the question is: if I have am array, how can I pass it as separated arguments to fmt.Sprintf
? Or: can I call a function passing an list of arguments in Go?
...string
argument, so I can't change the type to[]interface{}
without explicitly allocating a new slice and copying all of the elements over. – Reproach