Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.
/ conftags Public archive

Struct tag parser to get environment variables or default and fill a configuration struct

License

Notifications You must be signed in to change notification settings

Depado/conftags

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

conftags

Go Version Go Version Go Report Card Build Status codecov License

Similar to github.com/caarlos0/env but with default decoupled from environment. It also doesn't support slices.

This library intends to work as the last step in the filling of a configuration struct. Assuming that environment variables are the highest priority configuration values, you could first parse a configuration file, and then parse this struct with this library. The last resort is the default which will fill the struct field only if it has the zero value for its own type.

Usage

type MyConf struct {
    Int      int           `env:"INT" default:"10"`
    String   string        `env:"STRING"`
    Duration time.Duration `env:"DURATION" default:"1h"`
}

func (ms *MyConf) Parse() error {
    return conftags.Parse(ms)
}

About

Struct tag parser to get environment variables or default and fill a configuration struct

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages