Golang http /模板有替换功能,if
构造,但我没有找到for
构造.我怎样才能遍历切片?像这样:
{{for x in xs}}
Hello, {{x.Name}}!
{{end}}
Run Code Online (Sandbox Code Playgroud)
mat*_*ttn 15
使用 range
{{range xs}}
Hello, {{.Name}}!
{{end}}
Run Code Online (Sandbox Code Playgroud)