Skip to content

Instantly share code, notes, and snippets.

@jonvuri
Created June 24, 2019 19:35
Show Gist options
  • Save jonvuri/5020900a9b4fc83ee3ea68507a3db568 to your computer and use it in GitHub Desktop.
Save jonvuri/5020900a9b4fc83ee3ea68507a3db568 to your computer and use it in GitHub Desktop.
type templateParams struct {
first string
second string
}
func writeTemplate(w io.Writer, params templateParams) {
myTemplate, err := template.New("my-template").Parse(`prefix "{{.first}}" "{{.second}}" suffix`)
if err != nil {
log.Fatal("Error parsing template: ", err)
return
}
myTemplate.Execute(w, params)
}
func outputTemplte() {
params := templateParams{
first: "First",
second: "Second",
}
writeTemplate(os.Stdout, params)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment