Skip to content

saj1th/envtoflag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

envtoflag GoDoc

envtoflag is a lib to populate flags from environment variables (to support http://12factor.net/config)

USage

package main

import (
	"flag"
	"log"

	"github.com/saj1th/envtoflag"
)

func main() {
	var (
		mode string // dev|debug|prod
		port int    // port to listen to
	)

	flag.StringVar(&mode, "mode", "", "dev|debug|prod")
	flag.IntVar(&port, "port", 8080, "port to listen to")
	
	// export YOURPACKAGENAME_PORT=9090	
	envtoflag.Parse("yourpackagename")

	fmt.Printf("Mode: %s\nPort: %d\n\n", mode, port)

}

About

A lib to populate flags from environment variables to support http://12factor.net/config

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages