そのため、構造体からブール値をチェックする単純な if チェックを行っていますが、動作していないようで、HTML のレンダリングを停止するだけです。
したがって、次の構造体は次のようになります。
type Category struct {
ImageURL string
Title string
Description string
isOrientRight bool
}
これで、範囲とともに表示できる Category 構造体のスライスができました。
以下は、1 つの構造体の例です。
juiceCategory := Category{
ImageURL: "lemon.png",
Title: "Juices and Mixes",
Description: `Explore our wide assortment of juices and mixes expected by
today's lemonade stand clientelle. Now featuring a full line of
organic juices that are guaranteed to be obtained from trees that
have never been treated with pesticides or artificial
fertilizers.`,
isOrientRight: true,
}
以下のように複数の方法を試しましたが、どれもうまくいきませんでした。
{{range .Categories}}
{{if .isOrientRight}}
Hello
{{end}}
{{if eq .isOrientRight true}}
Hello
{{end}}
<!-- Print nothing -->
{{ printf .isOrientRight }}
{{end}}