go get?github.com/go-sql-driver/mysql
go get?github.com/lib/pq
無論是安裝那一條都會報錯,錯誤大致如下:
.../connection_go18.go:43: undefined: driver.TxOptions
.../connection_go18.go:55: undefined: sql.IsolationLevel
.../connection_go18.go:69: undefined: driver.NamedValue
.../connection_go18.go:88: undefined: driver.NamedValue
網(wǎng)上搜了好久,原因大概是安裝了老版本(1.7)的go,后來又安裝了新版本(1.8.3)的go。
解決辦法:刪除/usr/local/go,$GOPATH/pkg。重新安裝go。
刪除命令如下:
sudo rm -rf /usr/local/go
sudo rm -fr $GOPATH/pkg
付原地址:https://github.com/go-sql-driver/mysql/issues/638