summaryrefslogtreecommitdiff
path: root/get.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-26 22:41:47 -0500
committerJeff Carr <[email protected]>2025-10-26 22:41:47 -0500
commit4d0828def125f96d376cc1bd018bd3d8b0997901 (patch)
treeb683bbe08350c6e5b78eba65be9a6496091c874b /get.go
parent59c9500872620a0e43752d7ebf352804aaf49925 (diff)
rearranging filenames
Diffstat (limited to 'get.go')
-rw-r--r--get.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/get.go b/get.go
new file mode 100644
index 0000000..e783b94
--- /dev/null
+++ b/get.go
@@ -0,0 +1,38 @@
+package env
+
+import (
+ "errors"
+ "os/user"
+)
+
+func Get(flag string) string {
+ saveMu.Lock()
+ defer saveMu.Unlock()
+ if envPB == nil {
+ return ""
+ }
+ c := findByLower(flag)
+ if c == nil {
+ return ""
+ }
+
+ return c.Value
+}
+
+func GetAppname() (string, error) {
+ if APPNAME != "" {
+ return APPNAME, nil
+ }
+ return "", errors.New("your application must setup config.Init()")
+}
+
+func GetUsername() string {
+ if Get("username") != "" {
+ return Get("username")
+ }
+ usr, _ := user.Current()
+ if usr.Username != "" {
+ return usr.Username
+ }
+ return "notsure" // OS Idiocracy
+}