github.com/bilus/oya@v0.0.3-0.20190301162104-da4acbd394c6/cmd/internal/env.go (about) 1 package internal 2 3 import ( 4 "os" 5 "os/user" 6 "path/filepath" 7 8 "github.com/pkg/errors" 9 ) 10 11 func installDir() (string, error) { 12 homeDir, found := os.LookupEnv("OYA_HOME") 13 if !found { 14 user, err := user.Current() 15 if err != nil { 16 return "", err 17 } 18 19 if len(user.HomeDir) == 0 { 20 return "", errors.Errorf("Could not detect user home directory") 21 } 22 homeDir = user.HomeDir 23 } 24 25 return filepath.Join(homeDir, ".oya", "packs"), nil 26 } 27 28 func lookupOyaScope() (string, bool) { 29 return os.LookupEnv("OYA_SCOPE") 30 } 31 32 func setOyaScope(scope string) error { 33 return os.Setenv("OYA_SCOPE", scope) 34 }