World's easiest question for anyone but me: Why is go get github.com/go-sql-driver/mysql failing?

agolangf · 2016-10-23 17:00:11 · 667 次点击    
这是一个分享于 2016-10-23 17:00:11 的资源,其中的信息可能已经有所发展或是发生改变。

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:

Are you missing an export GOPATHin your rc file?

g0dsCookie:

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

-Nii-:

Where is your config set?

peterhellberg:

Your program needs to be in $GOPATH/src/foo/ (or more commonly $GOPATH/src/github.com/username/foo)


入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

667 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传