Skip to content
/ env Public

A small package that type cast environment variables to their basic type on the "go"

License

Notifications You must be signed in to change notification settings

Kansuler/env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kansuler/env

License Version Codacy Badge

A small package that gets environment variables and convert them to their purposed basic type. If invalid or unset, use the fallback value.

API and detailed documentation can be found at https://godoc.org/github.com/Kansuler/env

Installation

go get github.com/Kansuler/env

Usage example

import "github.com/Kansuler/env"

func main() {
    // get environment variable `test_environment` as bool, if not set use fallback value
    testEnv := env.Bool("test_environment", false)
    
    if testEnv {
        // Do test env stuff...
    }
}

Functions

func Bool(key string, fallback bool) bool

func String(key string, fallback string) string

func Bytes(key string, fallback []byte) []byte

func Runes(key string, fallback []rune) []rune

func Float32(key string, fallback float32) float32

func Float64(key string, fallback float64) float64

func Int(key string, fallback int) int

func Int8(key string, fallback int8) int8

func Int16(key string, fallback int16) int16

func Int32(key string, fallback int32) int32

func Int64(key string, fallback int64) int64

func Uint(key string, fallback uint) uint

func Uint8(key string, fallback uint8) uint8

func Uint16(key string, fallback uint16) uint16

func Uint32(key string, fallback uint32) uint32

func Uint64(key string, fallback uint64) uint64

func Uintptr(key string, fallback uintptr) uintptr

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

About

A small package that type cast environment variables to their basic type on the "go"

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages