Skip to content

getenv package is assign default value if env var is empty.

License

Notifications You must be signed in to change notification settings

ieee0824/getenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

2a0f44a · Dec 19, 2023

History

37 Commits
Jun 8, 2021
Jun 8, 2021
Jun 16, 2017
Dec 19, 2023
Jun 16, 2017
Jun 17, 2021
Jun 17, 2021
Jun 8, 2021
Jun 8, 2021
Jun 8, 2021
Aug 18, 2017
Aug 18, 2017
Dec 19, 2023
Dec 19, 2023
Jun 8, 2021
Jun 8, 2021
Dec 19, 2023
Dec 19, 2023
Jun 16, 2017
Jun 16, 2017

Repository files navigation

getenv

English | 日本語

This is a package for getting environment variables with arbitrary types.

CircleCI

example

import (
	"fmt"
	"github.com/ieee0824/getenv"
	"time"
	"os"
)


fmt.Println(getenv.Duration("ANY_ENV"))
fmt.Println(getenv.Duration("ANY_ENV", 60))
fmt.Println(getenv.Duration("ANY_ENV","120s"))
fmt.Println(getenv.Duration("ANY_ENV", 60 * time.Second))
fmt.Println(getenv.Duration("ANY_ENV", "1h30m20s"))

os.Setenv("ANY_ENV", "60h")
fmt.Println(getenv.Duration("ANY_ENV"))
fmt.Println(getenv.Duration("ANY_ENV", 60))
fmt.Println(getenv.Duration("ANY_ENV","120s"))
fmt.Println(getenv.Duration("ANY_ENV", 60 * time.Second))
fmt.Println(getenv.Duration("ANY_ENV", "1h30m20s"))

os.Setenv("ANY_ENV", "60h")
fmt.Println(getenv.Duration("ANY_ENV"))
fmt.Println(getenv.Duration("ANY_ENV", 60))
fmt.Println(getenv.Duration("ANY_ENV","120s"))
fmt.Println(getenv.Duration("ANY_ENV", 60 * time.Second))
fmt.Println(getenv.Duration("ANY_ENV", "1h30m20s"))
0s
1m0s
2m0s
1m0s
1h30m20s
60h0m0s
60h0m0s
60h0m0s
60h0m0s
60h0m0s
18h12m16s
18h12m16s
18h12m16s
18h12m16s
18h12m16s

About

getenv package is assign default value if env var is empty.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages