Skip to content

matansh/enver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

enver

A Go(lang) configuration library.

Usage

import "github.com/matansh/enver/config"

type Config struct {
	LogLevel          string `env:"LOG_LEVEL"`
	Port              int64  `env:"PORT"`
	FeatureFlag       bool   `env:"TURN_ON_FEATURE"`
	ExplicitlyIgnored string `env:"-"` // passing "-" instructs the lib not to populate this field
	ImplicitlyIgnored string           // untagged struct fields will be ignored
}

func main() {
	var cfg Config
	
	errs := config.LoadEnv(&cfg)
	if len(errs) != 0 {
		// failed to load config
	}
}

Background

This library is intended to help projects implement the twelve-factor app methodology - https://12factor.net/

footnote

This library is intentionally dependency-less in order to minimize the dependency trees of its importers, you are welcome ;)