You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

user_posix.go 419B

123456789101112131415161718192021222324
  1. // Package pq is a pure Go Postgres driver for the database/sql package.
  2. // +build aix darwin dragonfly freebsd linux nacl netbsd openbsd plan9 solaris rumprun
  3. package pq
  4. import (
  5. "os"
  6. "os/user"
  7. )
  8. func userCurrent() (string, error) {
  9. u, err := user.Current()
  10. if err == nil {
  11. return u.Username, nil
  12. }
  13. name := os.Getenv("USER")
  14. if name != "" {
  15. return name, nil
  16. }
  17. return "", ErrCouldNotDetectUsername
  18. }