osenv

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2020 License: BSD-3-Clause Imports: 1 Imported by: 3

README

OS environment variables helper.

Build Status Coverage Status Go.Dev reference Go Report Card Release

Usage

$ go get -u clevergo.tech/osenv
Get

Get returns the environment variable associated with the given key, a fallback(default) value will be returned if not exist.

Assume environment is that FOO=BAR EMPTY=.

Method Value
osenv.Get("FOO") BAR
osenv.Get("EMPTY") -
osenv.Get("EMPTY", "BUZZ") -
osenv.Get("FIZZ") -
osenv.Get("FIZZ", "BUZZ") BUZZ
SetNX

Sets an environment variable if not exist.

osenv.SetNX("NONEXISTENT", "VALUE")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(key string, fallback ...string) string

Get returns the environment variable associated with the given key. Returns the fallback value if not exist.

func SetNX

func SetNX(key, value string) error

SetNX sets the value of the environment variable named by the key if not exist.

Types

This section is empty.

Jump to

Keyboard shortcuts

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