From cba417e15f7ec6ca380b8b81c887503eda7c02b3 Mon Sep 17 00:00:00 2001 From: Hariom Verma Date: Fri, 22 Sep 2023 06:23:55 +0530 Subject: [PATCH] Add env --- internal/env/env.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 internal/env/env.go diff --git a/internal/env/env.go b/internal/env/env.go new file mode 100644 index 0000000..d527df0 --- /dev/null +++ b/internal/env/env.go @@ -0,0 +1,25 @@ +package env + +import ( + "fmt" + "os" + "path/filepath" +) + +type Env struct { + GNOROOT string + GNOHOME string +} + +func GnoHome() string { + dir := os.Getenv("GNO_HOME") + if dir != "" { + return dir + } + dir, err := os.UserConfigDir() + if err != nil { + panic(fmt.Errorf("couldn't get user config dir: %w", err)) + } + gnoHome := filepath.Join(dir, "gno") + return gnoHome +}