<p>Trying to use the go-sql-driver/mysql package. When I do this:</p>
<pre><code>go get github.com/go-sql-driver/mysql
</code></pre>
<p>I get the error <strong>package github.com/go-sql-driver/mysql: cannot download, $GOPATH not set. For more details see: go help gopath</strong></p>
<p>I have read <a href="https://golang.org/doc/code.html" rel="nofollow">https://golang.org/doc/code.html</a> 72 times and seem to be missing something. Here's my config. (By the way, a "hello world" program works just fine.)</p>
<pre><code>PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/usr/local/mysql/bin/:/bin
GOPATH=/Users/tom/go
</code></pre>
<p>The program named foo.go is in:</p>
<pre><code>/Users/tom/go/foo
</code></pre>
<p>What am I doing wrong?</p>
<hr/>**评论:**<br/><br/>bbrazil: <pre><p>Are you missing an <code>export GOPATH</code>in your rc file?</p></pre>g0dsCookie: <pre><p>You need to export GOPATH, otherwise go won't know the path. </p>
<p>export GOPATH=<path></p>
<p>or </p>
<p>GOPATH=<path>
export GOPATH</p>
<p>This should go into your .bashrc and you need to reload it with source .bashrc</p></pre>-Nii-: <pre><p>Where is your config set?</p></pre>peterhellberg: <pre><p>Your program needs to be in $GOPATH/src/foo/ (or more commonly $GOPATH/src/github.com/username/foo)</p></pre>
World's easiest question for anyone but me: Why is go get github.com/go-sql-driver/mysql failing?
agolangf · · 520 次点击这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传