environment

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitEnvironmentVariables

func InitEnvironmentVariables(envStorage EnvStorage) error

InitEnvironmentVariables init env for runtime

HOME: home path
PWD: binary path
UID: current user uid

Types

type DefaultEnvStorage

type DefaultEnvStorage struct{}

DefaultEnvStorage 记录所有的环境变量

func (*DefaultEnvStorage) All

func (es *DefaultEnvStorage) All() []string

All 获取所有环境变量

func (*DefaultEnvStorage) Get

func (es *DefaultEnvStorage) Get(key string) string

Get 获取指定环境变量

func (*DefaultEnvStorage) IsTrue

func (es *DefaultEnvStorage) IsTrue(key string) bool

IsTrue 1 or "true" 均设置为TRUE

func (*DefaultEnvStorage) Load

func (es *DefaultEnvStorage) Load(filename string) error

Load 从文件加载环境变量

func (*DefaultEnvStorage) Set

func (es *DefaultEnvStorage) Set(key string, value string)

Set 写入环境变量

type EnvStorage

type EnvStorage interface {
	Get(string) string
	Set(string, string)
	Load(string) error
	All() []string
	IsTrue(string) bool
}

EnvStorage 环境变量存储获取逻辑

func NewEnvStorage

func NewEnvStorage() EnvStorage

NewEnvStorage 创建环境变量存储

type FakeEnvStorage

type FakeEnvStorage struct {
	Envs        map[string]string
	CalledLoad  bool
	EnvsHistory map[string][]string
}

FakeEnvStorage holds fake environment variables

func NewFakeEnvStorage

func NewFakeEnvStorage() *FakeEnvStorage

NewFakeEnvStorage creates a new FakeEnvStorage

func (*FakeEnvStorage) All

func (f *FakeEnvStorage) All() (envs []string)

All get all environment variables

func (*FakeEnvStorage) Get

func (f *FakeEnvStorage) Get(key string) string

Get get environment variable value (fake behavior)

func (*FakeEnvStorage) IsTrue

func (f *FakeEnvStorage) IsTrue(key string) bool

IsTrue checks whether the given environment variable is to what would be a boolean value of true (fake behavior)

func (*FakeEnvStorage) Load

func (f *FakeEnvStorage) Load(filename string) error

Load load environment file (fake behavior)

func (*FakeEnvStorage) Set

func (f *FakeEnvStorage) Set(key string, value string)

Set set environment variable value (fake behavior)

Jump to

Keyboard shortcuts

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