Skip to content

Instantly share code, notes, and snippets.

@chadlung
Last active September 24, 2015 22:13
Show Gist options
  • Save chadlung/b6dd4326a6448b1d36b4 to your computer and use it in GitHub Desktop.
Save chadlung/b6dd4326a6448b1d36b4 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"log"
"github.com/spf13/viper"
_ "github.com/spf13/viper/remote"
)
func main() {
viper.AddRemoteProvider("consul", "192.168.33.10:8500", "/config/helloconfig.json")
viper.SetConfigType("json")
err := viper.ReadRemoteConfig()
if err != nil {
log.Fatal(err)
}
msg := viper.GetString("msg")
universalAnswer := viper.GetInt("the-answer")
fmt.Printf("\nMsg: %s\nUniversal Answer: %d\n", msg, universalAnswer)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment