3

Template

 2 years ago
source link: https://linuxsuren.github.io/blog/language/golang/template/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Template

Go Template

Action

1.条件语句 2.迭代 3.封装 4.引用

{{ if arg }}
  code
{{ end }}

{{ if arg }}
  code-1
{{ else }}
  code-2
{{ end }}
{{ range . }}
{{ end }}
{{ range $key, $value := . }}
  {{ $key }} {{ $value }}
{{ end }}
{{ index "abc" 0 }}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK