Skip to content

HiFX/env_parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

env_parser

A parser for parsing environment variables to a struct in golang

Usage

Get the package first.

go get github.com/shalinkktl/env_parser

Sample Program

type Source struct {
	Name string `env:"name;mandatory"`
	Age  int    `env:"age;optional;25"`
}

func main() {
	ep := env_parser.NewEnvParser()
	//set name : optional
	ep.Name("test_app")
	//set separator : optional
	ep.Separator("_")

	source := Source{}
	er := ep.Map(&source)
	if er != nil {
		fmt.Println("Error : ", er)
		return
	}
	fmt.Println("Final :", source)
}

About

A parser for parsing environment variables to a struct in golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages