以下代碼恐慌地tmp.Execute說function "copyrightYear" not definedimport ( "os" "html/template" "fmt")func main() { fm := template.FuncMap{ "copyrightYear": func() string { return fmt.Sprintf("%d", time.Now().Year()) }, } tmp := template.Must(template.New("").Parse("{{copyrightYear}}")).Funcs(fm) tmp.Execute(os.Stdout, nil)}我錯過了什么?我已經瀏覽了文檔。call copyrightYear在模板中將其更改為,或copyrightYear .不修復它。
- 1 回答
- 0 關注
- 267 瀏覽
添加回答
舉報
0/150
提交
取消