41 lines
621 B
Go
41 lines
621 B
Go
package environment
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
type Env struct {
|
|
Path string
|
|
|
|
Env map[string]string
|
|
|
|
// History where each command gets append to the end
|
|
History []string
|
|
}
|
|
|
|
func Get_env() Env {
|
|
pwd, err := os.Getwd()
|
|
if err != nil {
|
|
log.Fatal(err.Error())
|
|
}
|
|
return Env{
|
|
Path: pwd,
|
|
Env: inherit_environment(),
|
|
History: get_history(),
|
|
}
|
|
}
|
|
func inherit_environment() map[string] string{
|
|
env := make(map[string]string)
|
|
for _, s_env := range os.Environ() {
|
|
split := strings.Split(s_env, "=")
|
|
env[split[0]] = split[1]
|
|
}
|
|
return env
|
|
}
|
|
func get_history() []string {
|
|
var x []string
|
|
return x
|
|
}
|