Struct methods in Go templates are usually called same way as public struct properties but in this case it just doesn't work: http://play.golang.org/p/xV86xwJnjA
{{with index . 0}}
{{.FirstName}} {{.LastName}} is {{.SquareAge}} years old.
{{end}}
Error:
executing "person" at <.SquareAge>: SquareAge is not a field
of struct type main.Person
Same problem with:
{{$person := index . 0}}
{{$person.FirstName}} {{$person.LastName}} is
{{$person.SquareAge}} years old.
In constrast, this works:
{{range .}}
{{.FirstName}} {{.LastName}} is {{.SquareAge}} years old.
{{end}}
How to call SquareAge() method in {{with}} and {{$person}} examples?