diff options
| author | Jeff Carr <[email protected]> | 2025-10-22 15:54:31 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-22 15:54:31 -0500 |
| commit | e7467286e30dad228959f5f3f702a166f1ea289c (patch) | |
| tree | cbb65af7c276e11fc5eae5c0ba3a051d531075b3 /load.go | |
| parent | 072f59bbc6b49567da3dfd6fdd0a408dab860bdb (diff) | |
Init() logic was totally wrong
Diffstat (limited to 'load.go')
| -rw-r--r-- | load.go | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/load.go b/load.go deleted file mode 100644 index 2986819..0000000 --- a/load.go +++ /dev/null @@ -1,92 +0,0 @@ -package ENV - -import ( - "errors" - "os" - "path/filepath" - "strings" - - "go.wit.com/log" -) - -func loadENV() error { - if envPB != nil { - log.Info("envPB already loaded") - return errors.New("envPB already loaded") - } - filename, err := getConfigFilenameENV() - if err != nil { - return err - } - // log.Info("loadENV()", filename) - stuff, err := os.ReadFile(filename) - if err != nil { - return err - } - saveMu.Lock() - defer saveMu.Unlock() - envPB = NewKeys() - for _, line := range strings.Split(string(stuff), "\n") { - line = strings.TrimSpace(line) - if line == "" { - continue - } - parts := strings.Split(line, "=") - if len(parts) != 2 { - // log.Info("INVALID LINE:", i, line) - continue - } - c := new(Key) - c.Var = parts[0] - c.Value = parts[1] - envPB.Append(c) - // log.Printf("ENV LINE: (%v)\n", c) - } - - return err -} - -func getConfigFilenameENV() (string, error) { - appname, err := GetAppname() // already configured by your application - if err != nil { - return "", err - } - - configdir, err := getConfigDir() - if err != nil { - return "", err - } - - filename := filepath.Join(configdir, appname+".ENV") - return filename, nil -} - -func getCacheDir() (string, error) { - if Get("cacheDir") != "" { - return Get("cacheDir"), nil - } - - cacheDir, _ := os.UserCacheDir() - - appname, err := GetAppname() // application should have already configured this - if err != nil { - return cacheDir, err - } - - return filepath.Join(cacheDir, appname), nil -} - -func getConfigDir() (string, error) { - if Get("configDir") != "" { - return Get("configDir"), nil - } - - configDir, _ := os.UserConfigDir() - - appname, err := GetAppname() // application should have already configured this - if err != nil { - return configDir, err - } - - return filepath.Join(configDir, appname), nil -} |
