I would like to output slice[0].type using go templates. While printing works:
{{ index .Slice 0 | printf "%+v" }} // {Type:api.Meter ShortType:Meter VarName:meter}
printing the field doesn't:
{{ index .Slice 0 | .Type }} // template: gen:43:26: executing "gen" at <.Type>: can't evaluate field Type in type struct { API string; Package string; Function string; BaseTypes []main.baseType; Types map[string]main.typeStruct; Combinations [][]string }
The error message indicates that the outer loops fields are evaluated, not the result of the index call.
What is the correct syntax to access nested fields of slices?