V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
304464743
V2EX  ›  Go 编程语言

关于读取 yaml

  •  
  •   304464743 · 2019-04-07 17:02:18 +08:00 · 2346 次点击
    这是一个创建于 1817 天前的主题,其中的信息可能已经有所发展或是发生改变。

    本人初学者,想问下 go 读取 yaml 文件后能否像 python 一样直接按字典那样引用? 比如在 python 中,直接读入转换成字典后就可以 dict['global']['aa'] 引用

    而 go 中,make 新建字典(map[string]interface{})后,只可以引用第一层,引用到第二层好像就变成字符串了 dict['global']可以,dict['global']['aa']就报错了。参考了下 prometheus 的代码,是要定义 struct 和 yaml 中的格式一模一样,觉得这样太麻烦了,所以想问下能否像 python 那样?

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3145 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 12:41 · PVG 20:41 · LAX 05:41 · JFK 08:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.