Update README.md
This commit is contained in:
parent
8e0183a596
commit
a2e5f49857
23
README.md
23
README.md
@ -1,3 +1,26 @@
|
||||
# nacos-viper-remote
|
||||
|
||||
Golang configuration,use to Viper reading from remote Nacos config systems. Viper remote for Naocs.
|
||||
|
||||
```go
|
||||
runtime_viper := viper.New()
|
||||
|
||||
remote.SetOptions(&remote.Option{
|
||||
Url: "localhost",
|
||||
Port: 80,
|
||||
NamespaceId: "public",
|
||||
GroupName: "DEFAULT_GROUP",
|
||||
Config: remote.Config{ DataId: "config_dev" },
|
||||
Auth: nil,
|
||||
})
|
||||
|
||||
err := remote_viper.AddRemoteProvider("nacos", "localhost", "")
|
||||
remote_viper.SetConfigType("yaml")
|
||||
|
||||
_ = remote_viper.ReadRemoteConfig() //sync get remote configs to remote_viper instance memory . for example , remote_viper.GetString(key)
|
||||
_ = remote_viper.WatchRemoteConfigOnChannel() //async watch , auto refresh configs.
|
||||
|
||||
appName := remote_viper.GetString("key")
|
||||
|
||||
fmt.Println(appName)
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user