MCPcopy Create free account
hub / github.com/gogs/gogs / CurrentUsername

Function CurrentUsername

internal/osutil/osutil.go:44–59  ·  view source on GitHub ↗

CurrentUsername returns the username of the current user.

()

Source from the content-addressed store, hash-verified

42
43// CurrentUsername returns the username of the current user.
44func CurrentUsername() string {
45 username := os.Getenv("USER")
46 if len(username) > 0 {
47 return username
48 }
49
50 username = os.Getenv("USERNAME")
51 if len(username) > 0 {
52 return username
53 }
54
55 if user, err := user.Current(); err == nil {
56 username = user.Username
57 }
58 return username
59}

Callers 3

CheckRunUserFunction · 0.92
InstallFunction · 0.92
TestCurrentUsernameFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestCurrentUsernameFunction · 0.68