Logo

0x5a.live

for different kinds of informations and explorations.

GitHub - joshbetz/config: 🛠 A configuration library for Go that parses environment variables, JSON files, and reloads automatically on SIGHUP.

🛠 A configuration library for Go that parses environment variables, JSON files, and reloads automatically on SIGHUP. - joshbetz/config

Visit SiteGitHub - joshbetz/config: 🛠 A configuration library for Go that parses environment variables, JSON files, and reloads automatically on SIGHUP.

GitHub - joshbetz/config: 🛠 A configuration library for Go that parses environment variables, JSON files, and reloads automatically on SIGHUP.

🛠 A configuration library for Go that parses environment variables, JSON files, and reloads automatically on SIGHUP. - joshbetz/config

Powered by 0x5a.live 💗

config

Build Status Go Report Card

A small configuration library for Go that parses environment variables, JSON files, and reloads automatically on SIGHUP.

Example

func main() {
	c := config.New("config.json")

	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		var value string
		c.Get("value", &value)
		fmt.Fprintf(w, "Value: %s", value)
	})

	http.ListenAndServe(":3000", nil)
}

Reload config on SIGHUP

API

func New(file string) *Config

Constructor that initializes a Config object and sets up the SIGHUP watcher.

func (config *Config) Get(key string, v interface{}) error

Takes the path to a JSON file, the name of the configuration option, and a pointer to the variable where the config value will be stored. v can be a pointer to a string, bool, or float64.

func (config *Config) Reload()

Reloads the config. Happens automatically on SIGHUP.

GoLang Resources

are all listed below.

Resources

listed to get explored on!!

Made with ❤️

to provide different kinds of informations and resources.