if you make block ...interface{}, then you can just
pass it directly to fmt.Sprintf:
return fmt.Sprintf(main, block)
otherwise you'll have to use an intermediate function
with ... interface{} parameters, assign to that and then
call Sprintf.
e.g. (untested)
func format(f string, a ...string) (r string) {
func(b ...interface{}) {
b = make([]interface{}, len(a))
for i, s := range a {
b[i] = s
}
r = fmt.Sprintf(f, b)
}()
return
}
You don't need to repackage them.
func format(main string, block ...string) string {
return fmt.Sprintf(main, block)
}
The repository is full of examples of things like this and there are tools to do the searching for you. In this case there's even an example in Effective Go.
-rob
-rob