user.go 476 B

12345678910111213141516171819202122
  1. // Copyright 2015 - Present, The Gogs Authors. All rights reserved.
  2. // Copyright 2018 - Present, Gitote. All rights reserved.
  3. //
  4. // This source code is licensed under the MIT license found in the
  5. // LICENSE file in the root directory of this source tree.
  6. package user
  7. import (
  8. "os"
  9. )
  10. // CurrentUsername gets user username
  11. func CurrentUsername() string {
  12. curUserName := os.Getenv("USER")
  13. if len(curUserName) > 0 {
  14. return curUserName
  15. }
  16. return os.Getenv("USERNAME")
  17. }