Trying to use the go-sql-driver/mysql package. When I do this:
go get github.com/go-sql-driver/mysql
I get the error package github.com/go-sql-driver/mysql: cannot download, $GOPATH not set. For more details see: go help gopath
I have read https://golang.org/doc/code.html 72 times and seem to be missing something. Here's my config. (By the way, a "hello world" program works just fine.)
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/usr/local/mysql/bin/:/bin
GOPATH=/Users/tom/go
The program named foo.go is in:
/Users/tom/go/foo
What am I doing wrong?
评论:
bbrazil:
g0dsCookie:Are you missing an
export GOPATH
in your rc file?
-Nii-:You need to export GOPATH, otherwise go won't know the path.
export GOPATH=<path>
or
GOPATH=<path> export GOPATH
This should go into your .bashrc and you need to reload it with source .bashrc
peterhellberg:Where is your config set?
Your program needs to be in $GOPATH/src/foo/ (or more commonly $GOPATH/src/github.com/username/foo)
