genv

package
v1.15.2-0...-1a0745b Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package genv provides operations for environment variables of system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All() []string

All returns a copy of strings representing the environment, in the form "key=value".

func Build

func Build(m map[string]string) []string

Build builds a map to a environment variable slice.

func Contains

func Contains(key string) bool

Contains checks whether the environment variable named <key> exists.

func Get

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

Get returns the value of the environment variable named by the <key>. It returns given <def> if the variable does not exist in the environment.

func GetVar

func GetVar(key string, def ...interface{}) *gvar.Var

GetVar creates and returns a Var with the value of the environment variable named by the <key>. It uses the given <def> if the variable does not exist in the environment.

func GetWithCmd

func GetWithCmd(key string, def ...interface{}) *gvar.Var

GetWithCmd returns the environment value specified <key>. If the environment value does not exist, then it retrieves and returns the value from command line options. It returns the default value <def> if none of them exists.

Fetching Rules: 1. Environment arguments are in uppercase format, eg: GF_<package name>_<variable name>; 2. Command line arguments are in lowercase format, eg: gf.<package name>.<variable name>;

func Map

func Map() map[string]string

Map returns a copy of strings representing the environment as a map.

func Remove

func Remove(key ...string) error

Remove deletes one or more environment variables.

func Set

func Set(key, value string) error

Set sets the value of the environment variable named by the <key>. It returns an error, if any.

func SetMap

func SetMap(m map[string]string) error

SetMap sets the environment variables using map.

Types

This section is empty.

Jump to

Keyboard shortcuts

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