Skip to content

verystar/nacos-go-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nacos SDK for Golang

Usage

go get github.com/verystar/nacos-go-sdk/v2

Nacos Client

conf := nacos.NewClient("http://nacos.xxx.com", nacos.WithAccessTokenAuth("username", "password"))

// 异步监听配置
conf.ListenAsync("8b073ff4-1e58-41e9-ae72-37f8736bc9d4", "DEFAULT_GROUP", "test", func(cnf string) {
	// 重启程序
    os.Exit(1)
})

// 同步获取配置
conf.Get("8b073ff4-1e58-41e9-ae72-37f8736bc9d4", "DEFAULT_GROUP", "test")

Aliyun MSE Client

conf := nacos.NewClient("http://xxxx.mse.aliyun.com:8848", nacos.WithAccessKeyAuth("accessKeyId", "accessKeySecret"))

// 异步监听配置
conf.ListenAsync("8b073ff4-1e58-41e9-ae72-37f8736bc9d4", "DEFAULT_GROUP", "test", func(cnf string) {
	// 重启程序
    os.Exit(1)
})

// 同步获取配置
conf.Get("8b073ff4-1e58-41e9-ae72-37f8736bc9d4", "DEFAULT_GROUP", "test")