Reputation: 859
I need to set a variable at the beginning of my package that will later on be populated with parseFiles() but im not sure how to set the variable considering its not a string or int or anything generic like that. How would i set the variable without having to add some arbitrary name in there just to set it?
var templatefiles = template.New("foo") // Im having to do New("foo") just to set the variable
// Later on adding files to original variable
templatefiles.New("template name").Parse("Template text here")
Upvotes: 3
Views: 1859
Reputation: 53488
You just need to replace = template.New("foo")
with the type returned. In this case:
var templatefiles *template.Template // the return type of html/template.New()
templatefiles is now a global variable that contains a nil pointer to a type template.Template
.
Upvotes: 5