Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Add env
Browse files Browse the repository at this point in the history
  • Loading branch information
harry-hov committed Sep 22, 2023
1 parent 3d14f2b commit cba417e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions internal/env/env.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit cba417e

Please sign in to comment.