Iterate over .GitInfo

Config.toml contains enableGitInfo = true.

{{ .GitInfo.Hash }} returns the hash value, as expected.

I’d like to iterate over the .GitInfo collection:

{{ range .GitInfo }}
  {{ . }}<br>
{{ end }}

This generates an error:

executing “_default/single.html” at <.GitInfo>: range can’t iterate over {615a1d50e6628eb15eea7c99999bffc8bcfca1ec 615a1d5 Initial commit. John Smith jsmith@example.com 2017-09-23 08:32:47 -0400 EDT}

I thought this should work similar to:

{{ range .Params }}
  {{ . }}<br>
{{ end }}

What am I doing wrong? Thanks in advance for your help.

GitInfo is a struct and not a list/map – i.e. you cannot range over it. You have to access the fields by name.

If you just want to know the whole value of .GitInfo, you can do:

{{ printf "GitInfo debug:: %#v" $.GitInfo }}

I don’t like it prints the email too though, so I just print each item individually once I figured out what that struct contains: