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.

24 lines
409 B

  1. // Package pq is a pure Go Postgres driver for the database/sql package.
  2. // +build darwin dragonfly freebsd linux nacl netbsd openbsd 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. }