bbash/environment/environment.go
Tobias P.L Wennberg 6a94165e54 Bether input
2025-01-12 14:42:23 +01:00

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
}