在 golang 中使用 HTML 模板,如何在 HTML 中打印给定数据的索引?

Using HTML Template with golang, how do I print index of the given data in the HTML?

我正在做学校作业,我需要使用 go 做一个 Html 模板,我给它一个 go 获取的数据,如果可能的话我想在 html 中打印数据的第一个索引(用于测试它可能是其他索引)(数据全部由 . in html 调用。艺术家有一个组列表,我只想打印第一个但 {{.艺术家 [0]}} 使我的 html) 崩溃 我在互联网上没有找到其他方法 'range' 但我无法获得我想要的索引值 我只得到打印的每个名称的索引 :

{{range $i, $Artists := .Artists}}
            {{$i $Artists}}
        {{end}} 

我从网上试过的。我尝试了 $Artists$0 和其他东西但没有成功,我知道我可以使用 go form 但我想在 html 中尝试它。 预先感谢您的帮助:)

编辑:(执行没有问题。艺术家打印所有组,但我现在只想打印一个特定的组)

You want to print the first element of $Artists? Use the index function: {{index $Artists 0}}

多亏了 icza,这就是我要找的!