Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,17 @@ func TestBadConn(t *testing.T) {
// TestCloseBadConn tests that the underlying connection can be closed with
// Close after an error.
func TestCloseBadConn(t *testing.T) {
nc, err := net.Dial("tcp", "localhost:5432")
env := parseEnviron(os.Environ())
host := env["host"]
port := env["port"]
if host == "" {
host = "localhost"
}
if port == "" {
port = "5432"
}
addr := net.JoinHostPort(host, port)
nc, err := net.Dial("tcp", addr)
if err != nil {
t.Fatal(err)
}
Expand Down
24 changes: 24 additions & 0 deletions user_plan9.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Package pq is a pure Go Postgres driver for the database/sql package.

// +build plan9

package pq

import (
"os"
"os/user"
)

func userCurrent() (string, error) {
u, err := user.Current()
if err == nil {
return u.Username, nil
}

name := os.Getenv("user")
if name != "" {
return name, nil
}

return "", ErrCouldNotDetectUsername
}