github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/pkg/gnoenv/gnohome.go (about) 1 package gnoenv 2 3 import ( 4 "fmt" 5 "os" 6 "path/filepath" 7 ) 8 9 func HomeDir() string { 10 // if environment variable is set, always use that. 11 // otherwise, use config dir (varies depending on OS) + "gno" 12 13 dir := os.Getenv("GNOHOME") 14 if dir != "" { 15 return dir 16 } 17 18 // XXX: `GNO_HOME` is deprecated and should be replaced by `GNOHOME` 19 // keeping for compatibility support 20 dir = os.Getenv("GNO_HOME") 21 if dir != "" { 22 return dir 23 } 24 25 var err error 26 dir, err = os.UserConfigDir() 27 if err != nil { 28 panic(fmt.Errorf("couldn't get user config dir: %w", err)) 29 } 30 gnoHome := filepath.Join(dir, "gno") 31 32 // XXX: added april 2023 as a transitory measure - remove after test4 33 fixOldDefaultGnoHome(gnoHome) 34 return gnoHome 35 }