Skip to content

Instantly share code, notes, and snippets.

@morrxy
Created August 17, 2017 06:53
Show Gist options
  • Select an option

  • Save morrxy/7e35b072af973f9fc532c728ad8cba8b to your computer and use it in GitHub Desktop.

Select an option

Save morrxy/7e35b072af973f9fc532c728ad8cba8b to your computer and use it in GitHub Desktop.
[template data choice] 用map还是用struct #golang

https://stackoverflow.com/questions/12484398/global-template-data

An important distinction between applying a template to a struct vs. to a map: with a map, you can make references in your template which don't exist in your map; the template will execute with no errors and the references will just be empty. If you process against a struct and make a reference to something that doesn't exist in your struct, the template execution returns an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment