summaryrefslogtreecommitdiff
path: root/appname.go
blob: 98d8dcc9f01fb53621a77d61cd71602aad24e58c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package ENV

import (
	"errors"
	"os/user"
)

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
}