In Go, it's possible to prefix the final parameter in a function with the ... notation to indicate it is a variadic parameter.
template.ParseFiles is one such function:
func (t *Template) ParseFiles(filenames ...string) (*Template, error)
I am trying to create a function of my own which sets up various common features of my templates and I'd like the calling function to pass in the list of files that need to be parsed but I'm not sure how.
For example if my code looked like this:
type templateMap map[string]*template.Template
func (tmpl templateMap) AddTemplate(name string, files ...string) {
tmpl[name] = template.Must(template.ParseFiles(files)).Delims("{@","@}")
}
I get an error:
cannot use files (type []string) as type string in function argument
How do I wrapper variadic parameters?