Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyofx authored Apr 29, 2021
1 parent a2e5f49 commit 1b74386
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
Golang configuration,use to Viper reading from remote Nacos config systems. Viper remote for Naocs.

```go
runtime_viper := viper.New()
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,
})
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")
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.
_ = 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")
appName := remote_viper.GetString("key") // sync get config by key

fmt.Println(appName)
fmt.Println(appName)
```

0 comments on commit 1b74386

Please sign in to comment.