Skip to content

Hearst-DD/gappconfig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

GappConfig: Simple environment config loader

GappConfig is a simple way to load config parameters from environment variables. It is designed to be invoked by a service at startup.

Install

go get github.com/Hearst-DD/gappconfig

Use

import "github.com/Hearst-DD/gappconfig"

func main() {
	// prefix causes gappconfig to load all vars with the given prefix, e.g. MYSERVICE_ENV
	config = gappconfig.New("MYSERVICE_", gappconfig.Map{
		{"ENV", "dev"},
		{"PRETTY", true},
		{"LOG_LEVEL", "DEBUG"},
		{"HOST", "localhost"},
		{"PORT", 4001},
		{"SERVER_TIMEOUT", time.Second*30},
		// ...
	})

	host := config.String("HOST")
	port := config.Int("PORT")
	timeout := config.Duration("SERVER_TIMEOUT")
	prettyPrint := config.Bool("PRETTY")
}

About

Simple environmental config loader for services

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages