如何获取文本/模板中的循环切片键?

时间:2017-05-10 10:14:37

标签: go

例如

{{ range $k, $v := .rec}}
{{ $k }} :: {{ $v }}
{{ end }}

抓取错误panic: template: let:2:19: executing "let" at <.rec>: can't evaluate field rec in type []string

1 个答案:

答案 0 :(得分:-1)

{{ range $k, $v := .}}
{{ $k }} :: {{ $v }}
{{ end }}