envloader

package module
v0.0.0-...-66c992b Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 3 Imported by: 4

README

envloader

Simple go utility for env config loading and validation

Get with:

go get github.com/amaro0/envloader
How to use
package main

import (
	"fmt"
	"github.com/amaro0/envloader"
)

type someConf struct {
	Port    string `env:"PORT" envDefault:"3002" validate:"numeric"`
	GinMode string `env:"GIN_MODE" envDefault:"debug" validate:"oneof=debug release"`
}

func main() {
	err, conf := envloader.Load(someConf{})

	if err != nil {
		panic(err)
	}

	someConfInstance := conf.(*someConf)

	fmt.Println(someConfInstance)
}

You can tag your struct with options from both go-playground/validator and caarlos0/env

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(configStruct interface{}) (error, interface{})

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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