goconf

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: MIT Imports: 5 Imported by: 4

README

Go Config

Library to load env configuration

How to use it
type Conf struct {
	Name string `env:"MY_NAME"`
}

var Config Conf

func (Conf) Register() {
	err := env.Parse(&Config)
	if err != nil {
		log.Fatal("error loading stream goconf, ", err)
	}
}

func (Conf) Validate() {
	if Config.Name == "" {
		log.Fatal(`MY_NAME environmental variable cannot be empty`)
	}
}

func (Conf) Print() interface{} {
	return Config
}

func main() {
	config.Load(
		new(Conf),
	)
    log.Info(`configuration loaded, `,Config.Name)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(configs ...Configer)

Types

type Configer

type Configer interface {
	Register()
}

type Printer

type Printer interface {
	Print() interface{}
}

type Validater

type Validater interface {
	Validate()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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