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) 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 环境变量存储获取逻辑
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)
Click to show internal directories.
Click to hide internal directories.