Skip to content

runcfg/runcfg-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RunCfg Go Client

Usage in projects

First download dependency using go get

$ go get -u github.com/runcfg/runcfg-go

Then import into your project

import "github.com/runcfg/runcfg-go"

Using your first config

  1. Create an account at https://runcfg.com
  2. Download your .runcfg file from your project page at https://runcfg.com by clicking (get .runcfg file)

runcfg.PNG

  1. Place your .runcfg file at the root of your project
  2. Create an instance of the client in your code as follows:
// my-config is your project name which is prepended to your .runcfg file e.g. `my-config.runcfg`

client, err := runcfg.Create("my-config") 
if err != nil {
    t.Error(err)
}
  1. create your config type
type ExampleConfig struct {
	Version string `json:"version"`
	Target  string `json:"target"`
	Enabled string `json:"enabled"`
}
  1. load your remote config into your config type
var config ExampleConfig // create instance of your config type

err = client.LoadConfigAsType(&config)
if err != nil {
	log.Fatalf("LoadConfigAsType failure:\n%s", err)
}

// optional: watch for config changes and invoke callback
client.Watch(watchInterval, func() {
	fmt.Println("config updated")
})	

You can now access your configuration from the config type which you passed into the LoadConfigAsType function for example:

About

runcfg go client

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages