我在golang包中使用了text/template来解析环境中json字符串中的文本。

示例:https://play.golang.org/p/uARnrOyG4Th

但是我有一个错误:2009/11/10 23:00:00 Execute: template: Person template:1:19: executing "Person template" at <.id>: can't evaluate field id in type string
请帮我解决问题。我找不到基于库文档的错误。

最佳答案

模板不能直接应用于字符串,您应创建一个结构,然后将JSON字符串解码到该结构实例。 try the code

09-09 23:54
查看更多