conftags

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2017 License: MIT Imports: 6 Imported by: 2

README

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)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(in interface{}) error

Parse parses the function

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL