CurrentUsername returns the username of the current user.
()
| 42 | |
| 43 | // CurrentUsername returns the username of the current user. |
| 44 | func 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 | } |
no outgoing calls