envfile

package module
v0.0.0-...-2f768c4 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2022 License: MIT Imports: 9 Imported by: 1

README

envfile

Simple Envfile w YAML

Will try the following files and add contents to env:

  • file from ENV variable eg: ENV=~/env.yaml myprogram or export ENV=~/env.yaml; myprogram
  • file env.yaml in the current directory
  • file .env.yaml in the user home

In case no files are found it will continue silently

Usage:

Sample env.yaml
OV_BASEPATH: https://xxx.yyy.zzz
OV_USER: admin
OV_PASS: XXX
DSN: "host=localhost user=test password=xxx dbname=test port=5432 sslmode=disable TimeZone=America/Sao_Paulo"
REDIS: "redis://localhost:6379/1"
ADDR_API: :10081
ADDR_APP: :10080
envfile.Load()
\\...
os.Getenv("DSN")
envfile.Must("DSN") //similar to os.Getenv, but will panic in case env var is not found
envfile.Env("DSN","MYDEFAULTVALUE") //similar to os.Getenv, but in case var is not found, will return default value
method Env and Must

envfile provides different methods Env and Must. Each will provided type value for env vars to be used.

Env methods allow you to provide a default value, in case that var is not found.

Must methods all panic in case the var is not found.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OnVar func(k string, v string) = func(k string, v string) {

}

Functions

func Env

func Env(k string, def ...string) string

func EnvB

func EnvB(k string, def bool) bool

func EnvF64

func EnvF64(k string, def float64) float64

func EnvI

func EnvI(k string, def int) int

func EnvI64

func EnvI64(k string, def int64) int64

func From

func From() map[string]string

func GetUsage

func GetUsage() map[string][]byte

func Load

func Load()

func Must

func Must(k string) string

func MustB

func MustB(k string) bool

func MustF64

func MustF64(k string) float64

func MustI

func MustI(k string) int

func MustI64

func MustI64(k string) int64

Types

This section is empty.

Jump to

Keyboard shortcuts

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