summaryrefslogtreecommitdiffstats
path: root/modules/user
diff options
context:
space:
mode:
Diffstat (limited to 'modules/user')
-rw-r--r--modules/user/user.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/modules/user/user.go b/modules/user/user.go
new file mode 100644
index 0000000000..8a2557f327
--- /dev/null
+++ b/modules/user/user.go
@@ -0,0 +1,18 @@
+// Copyright 2014 The Gogs Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package user
+
+import (
+ "os"
+)
+
+func CurrentUsername() string {
+ curUserName := os.Getenv("USER")
+ if len(curUserName) > 0 {
+ return curUserName
+ }
+
+ return os.Getenv("USERNAME")
+}