envi

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: LGPL-2.1 Imports: 2 Imported by: 6 modules, 6 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

envi

A simple library for reading environment variables: converts to Go types, provides default values.

Useful for e.g. feature flags managed in the local environment.

Example

(Also see env_test.go.)

package main

import (
	"fmt"
	"os"

	"github.com/stevegt/envi"
)

func main() {
	fmt.Println(envi.String("SHELL", "foo"))
	fmt.Println(envi.Int("SHLVL", 99))
	fmt.Println(envi.Bool("IAmNotSet", true))
	fmt.Println(envi.Float32("somefloat", 2.34))
	os.Setenv("somefloat", "1.23")
	fmt.Println(envi.Float64("somefloat", 2.34))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(key string, def bool) (res bool)

func Float32

func Float32(key string, def float32) (res float32)

func Float64

func Float64(key string, def float64) (res float64)

func Int

func Int(key string, def int) (res int)

func String

func String(key string, def string) (res string)

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
⌂ 换网址