Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
html模板中的Golang打印数组值_Html_Http_Templates_Go - Fatal编程技术网

html模板中的Golang打印数组值

html模板中的Golang打印数组值,html,http,templates,go,Html,Http,Templates,Go,我不知道如何将数组中的值打印到html模板中 这是我的结构 type Lampen struct { Values [10]string } 我使用模板的代码如下 title := "moodlights" p := &lampen.Lampen{} err := p.LoadLampValues(title) if err != nil { log.Printf("Error loading Config File") for i := range p.Values

我不知道如何将数组中的值打印到html模板中 这是我的结构

type Lampen struct {
Values [10]string
}
我使用模板的代码如下

title := "moodlights"
p := &lampen.Lampen{}
err := p.LoadLampValues(title)
if err != nil {
    log.Printf("Error loading Config File")
    for i := range p.Values {
        p.Values[i] = "0"

    }
}
t, _ := template.ParseFiles("template.html")
t.Execute(w, p)
    "Values": [
    "\u003e",
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    ""
]
它所做的是从JSON文件加载值。 但是现在我不知道如何将这些值打印到html文件中。 工作原理如下:

<div>Lampe0: <input type="text" name="Lampe0" value={{index .Values 0}} maxlength="6"></div>
这相当于>,打印的html将

<div>Lampe0: <input type="text" name="Lampe0" value=> maxlength="6"></div>
所以它并没有逃脱

如何将其打印到html中以使其转义

更新2:
带有转义的旧工作版本可以在

上看到,好吧,我似乎使用的是文本/模板,而不是html/模板。所以这基本上是我的错。感谢JimB指出这一点。

您使用的是html/模板吗?是的,我正在使用html/模板。如前所述,问题在于,如果你现在输入了>,请举例说明你的意思