diff options
Diffstat (limited to 'compiler_wrapper/env.go')
-rw-r--r-- | compiler_wrapper/env.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/compiler_wrapper/env.go b/compiler_wrapper/env.go new file mode 100644 index 00000000..3c106d4a --- /dev/null +++ b/compiler_wrapper/env.go @@ -0,0 +1,37 @@ +package main + +import ( + "os" +) + +type env interface { + getenv(key string) string + environ() []string + getwd() string +} + +type processEnv struct { + wd string +} + +func newProcessEnv() (env, error) { + wd, err := os.Getwd() + if err != nil { + return nil, err + } + return &processEnv{wd: wd}, nil +} + +var _ env = (*processEnv)(nil) + +func (env *processEnv) getenv(key string) string { + return os.Getenv(key) +} + +func (env *processEnv) environ() []string { + return os.Environ() +} + +func (env *processEnv) getwd() string { + return env.wd +} |