Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 1.36 KB

README.md

File metadata and controls

54 lines (40 loc) · 1.36 KB

go-env-default

Go Reference Go Report Card codecov Go Tests GitHub go.mod Go version

import "github.com/caitlinelfring/go-env-default"

A collection of helper go functions for accessing the value of environment variables with pre-defined default values, including type conversion.

Supports the following types:

  • string
  • bool
  • int
  • int64
  • float64
  • time.Duration

Supported Go versions:

  • 1.17
  • 1.16
  • 1.15

Usage

Example:

package main

import (
  "fmt"

  env "github.com/caitlinelfring/go-env-default"
)

func main() {
  fmt.Println(env.GetDefault("MY_ENV_VAR", "foo"))
}
$ go run main.go
foo
$ MY_ENV_VAR=bar go run main.go
bar