Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the go1.3 compatibility issue #20

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
9 changes: 8 additions & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,14 @@ func Connect(connStr string, logLevel LogLevel) (conn *Conn, err error) {
tcpConn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", params.Host, params.Port))
panicIfErr(err)

panicIfErr(tcpConn.SetDeadline(time.Unix(int64(params.TimeoutSeconds*1000*1000*1000), 0)))
// Handling the timeout using SetDeadline and an absolute date
// 0 if no timeout
noDeadline := time.Time{}
if params.TimeoutSeconds <= 0 {
panicIfErr(tcpConn.SetDeadline(noDeadline))
} else {
panicIfErr(tcpConn.SetDeadline(time.Now().Add(time.Duration(params.TimeoutSeconds)*time.Second)))
}

newConn.tcpConn = tcpConn

Expand Down