<p>EDIT: Solved, see my comment below.</p>
<hr/>
<p>I am trying to compile go-ethereum. I am using kubuntu 17.10 amd64 and have installed go and vscode using snap:</p>
<pre><code>sudo snap install --classic go
sudo snap install --classic vscode
</code></pre>
<p>I have installed the go extension recommended by vscode. I have configured vscode in the following settings:</p>
<pre><code>{
"git.path": "/usr/bin/git",
"editor.wordWrap": "on",
"go.gopath": "/home/aerhv/go"
}
</code></pre>
<p>Also, the location of go:</p>
<pre><code>$ which go
/snap/bin/go
</code></pre>
<p>$GOBIN contains the binaries dlv, gocode, godef, godoc, golint, go-outline, gopkgs, goreturns, and go-symbols.</p>
<p>The output of my go env is:</p>
<pre><code>GOARCH="amd64"
GOBIN="/home/aerhv/go/bin"
GOCACHE="/home/aerhv/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/aerhv/go"
GORACE=""
GOROOT="/snap/go/1473"
GOTMPDIR=""
GOTOOLDIR="/snap/go/1473/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build085018022=/tmp/go-build -gno-record-gcc-switches"
</code></pre>
<p>Now, whenever I open a .go file, vscode notifies me to install the packages that I mentioned above contained in $GOBIN.</p>
<ol>
<li>Have I successfully installed the packages? I can run them on bash, but vscode doesn't seem to recognize this.</li>
<li>Have I missed something? I remember this setting working before but not using snap package manager, I was using apt before.</li>
</ol>
<p>fyi I have googled and stackoverflow-ed to no avail. The solutions provided seem to work on them but not on my case, I have no idea why. Please help thank you in advance :)</p>
<hr/>**评论:**<br/><br/>lighthousecookie: <pre><p>I have solved the problem. GOPATH must be set to an absolute path, not relative. While all of my settings follows it, my workspace settings on vscode was set to relative.</p>
<p>The solution is to change the workspace setting from:</p>
<pre><code>{ "go.gopath": "$GOPATH" }
</code></pre>
<p>to:</p>
<pre><code>{ "go.gopath": "/home/aerhv/go" }
</code></pre></pre>jh125486: <pre><p>On Ubuntu I would use “godeb” to install Go. My gut is saying that $GOROOT is not right. </p></pre>lighthousecookie: <pre><p>$GOROOT points to /snap/go/1473 with the following contents:</p>
<pre><code>api CONTRIBUTING.md gowrapper PATENTS src
AUTHORS CONTRIBUTORS lib pkg test
bin doc LICENSE README.md VERSION
command-gofmt.wrapper favicon.ico meta robots.txt
command-go.wrapper gofmtwrapper misc snap
</code></pre>
<p>Is this correct? If $GOROOT's contents aren't supposed to be like these, then please enlighten me</p></pre>pdffs: <pre><p>I suspect your difficulties are all related to snap, but unfortunately, I don't have much experience with it.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传