GOPATH is set for my shell, but not for 'go env'

xuanbao · · 567 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p><strong>edit</strong></p> <p>Found my problem, which was twofold. First, it needed to be in .zshenv instead of .zprofile (I had everything in .zprofile because of compiled-in behavior with Arch which has some quirks with .zshenv and $PATH). Second, it needed to be <code>export GOPATH=[...]</code> instead of just <code>GOPATH=[...]</code>.</p> <p><strong>/edit</strong></p> <p>Title explains it pretty well. I only have this problem with GOPATH and no other env vars. Similar questions online only offer <code>export GOPATH=[...]</code> as a solution, which isn&#39;t really fixing the problem. I&#39;m not using <code>sudo</code> to invoke go either.</p> <p>Let&#39;s check that it&#39;s in my .zprofile:</p> <p><code>cat ~/.zprofile | grep GOPATH</code></p> <pre><code>GOPATH=/home/killallnarcissists/src/go </code></pre> <p>Oh okay, let&#39;s make sure my terminal got that:</p> <p><code>echo $GOPATH</code></p> <pre><code>/home/killallnarcissists/src/go </code></pre> <p>That&#39;s strange, let&#39;s see what go makes of this:</p> <p><code>go env | grep GOPATH</code></p> <pre><code>GOPATH=&#34;&#34; </code></pre> <p>wat. Just to verify that <code>export</code> works...</p> <p><code>export GOPATH=/home/killallnarcissists/src/go</code></p> <p><code>go env | grep GOPATH</code></p> <pre><code>GOPATH=&#34;/home/killallnarcissists/src/go&#34; </code></pre> <hr/>**评论:**<br/><br/>Crast: <pre><p>I&#39;m less familiar with zsh than bash, but if it&#39;s like bash, then simply exporting the variable in your zprofile file (just like you did when testing it later on) is all that&#39;s missing.</p></pre>sihnon: <pre><p>What version of Go?</p> <p>How did you install it?</p> <p>Is there any chance your go command is an alias or wrapper script?</p></pre>killallnarcissists: <pre><p><code>go version</code></p> <pre><code>go version go1.6.1 gccgo (GCC) 6.1.1 20160602 linux/amd64 </code></pre> <p>Installed <code>gcc-go</code> from Arch&#39;s &#39;core&#39; repo, and it&#39;s not aliased.</p> <p><strong>edit</strong>: I also installed <code>go</code> from Arch&#39;s &#39;community&#39; repo and it&#39;s the same story.</p></pre>sihnon: <pre><p>Hm. Does it show correctly when you run this?</p> <pre><code>env GOPATH=/home/killallnarcissists/src/go go env | grep GOPATH </code></pre></pre>killallnarcissists: <pre><p>I edited my original post, it&#39;s fixed now. Thanks though!</p></pre>

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

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