我是新手,我正在使用 viper 加载我的所有配置,目前我拥有的是 YAML,如下所示
countryQueries:
sg:
- qtype: gmap
qplacetype: postal_code
- qtype: gmap
qplacetype: address
- qtype: geocode
qplacetype: street_address
hk:
- qtype: gmap
qplacetype: postal_code
- qtype: gmap
qplacetype: address
- qtype: geocode
qplacetype: street_address
请注意,国家代码是动态的,可以随时为任何国家添加。那么我如何将其映射到从技术上讲我可以做到的结构
for _, query := range countryQueries["sg"] { }
我尝试通过循环自己构建它,但我被困在这里
for country, queries := range viper.GetStringMap("countryQueries") {
// i cant seem to do anything with queries, which i wish to loop it
for _,query := range queries {} //here error
}