user.go 416 B

123456789101112131415161718192021
  1. // Copyright 2015 The Gogs Authors. All rights reserved.
  2. // Copyright 2018 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. func CurrentUsername() string {
  11. curUserName := os.Getenv("USER")
  12. if len(curUserName) > 0 {
  13. return curUserName
  14. }
  15. return os.Getenv("USERNAME")
  16. }