package mainimport("fmt""github.com/apolloconfig/agollo/v4""github.com/apolloconfig/agollo/v4/env/config")funcmain(){c :=&config.AppConfig{AppID:"2222",Cluster:"dev",IP:"http://192.168.0.52:8080/",NamespaceName:"100086.properties",IsBackupConfig:true,Secret:"36ae07ed3b8d4885b2c7fa8538c091c1",}client,_:= agollo.StartWithConfig(func()(*config.AppConfig,error){return c,nil})fmt.Println("初始化Apollo配置成功")//Use your apollo key to testcache := client.GetConfigCache(c.NamespaceName)value,_:= cache.Get("2323423")fmt.Println(value)}
json类型
package mainimport("fmt""github.com/apolloconfig/agollo/v4""github.com/apolloconfig/agollo/v4/env/config")funcmain(){c :=&config.AppConfig{AppID:"2222",Cluster:"dev",IP:"http://192.168.0.52:8080/",NamespaceName:"1008611.json",IsBackupConfig:true,Secret:"36ae07ed3b8d4885b2c7fa8538c091c1",}client,_:= agollo.StartWithConfig(func()(*config.AppConfig,error){return c,nil})fmt.Println("初始化Apollo配置成功")//Use your apollo key to testcache := client.GetConfigCache(c.NamespaceName)cache.Range(func(key, value interface{})bool{fmt.Println(key, value)returntrue})// fmt.Println(value)}