我在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