<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't really fixing the problem. I'm not using <code>sudo</code> to invoke go either.</p>
<p>Let's check that it'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's make sure my terminal got that:</p>
<p><code>echo $GOPATH</code></p>
<pre><code>/home/killallnarcissists/src/go
</code></pre>
<p>That's strange, let's see what go makes of this:</p>
<p><code>go env | grep GOPATH</code></p>
<pre><code>GOPATH=""
</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="/home/killallnarcissists/src/go"
</code></pre>
<hr/>**评论:**<br/><br/>Crast: <pre><p>I'm less familiar with zsh than bash, but if it's like bash, then simply exporting the variable in your zprofile file (just like you did when testing it later on) is all that'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's 'core' repo, and it's not aliased.</p>
<p><strong>edit</strong>: I also installed <code>go</code> from Arch's 'community' repo and it'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's fixed now. Thanks though!</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传