使用的github.com/bmizerany/pq, 今天从mysql转换到postgresql, golang的postgresql的pq库在win下有问题, 就是非常慢,在linux是没问题的,快得很.
https://github.com/lib/pq/issues/69 <= 这里有提及, 按照文中修改,在windows下就没问题了: 抄过来修改方法吧!修改 conn.go: conn.go, line 23...
var ( ErrSSLNotSupported = errors.New(“pq: SSL is not enabled on the server”) ErrNotSupported = errors.New(“pq: invalid command”) systemUsername = “” )
conn.go, line 69…
if o.Get("user") == "" { if systemUsername == "" { u, err := user.Current() if err != nil { return nil, err } else { systemUsername = u.Username } } o.Set("user", systemUsername) }
另一个连接库https://github.com/lxn/go-pgsql还没有试过,看英文资料是没问题的,但看代码要改很多东西啊, 所以有时间再搞.