DRYな備忘録

Don't Repeat Yourself.

go templateで、スライスの特定インデックスにアクセスしたい

あかんやつ

Can I access index directly?
the second is: {{.Bars[1]}}
panic: template: :2: unexpected bad character U+005B '[' in command

ヒィィ

うごくやつ

Can I access index directly?
the second is: {{index .Bars 1}}

The Go Playground

リファレンス

教訓

  • text/templateのほうのドキュメントを参照しましょうね

DRY

追記です

otiai10.hatenablog.com