在安装完 VS Code 后开始安装 go 的插件发现有如下错误
wohu@wohu:~/GoCode/src$ go install github.com/nsf/gocode
# github.com/nsf/gocode
github.com/nsf/gocode/package_ibin.go:99: r.declReader.Reset undefined (type bytes.Reader has no field or method Reset)
github.com/nsf/gocode/package_ibin.go:148: undefined: io.SeekCurrent
github.com/nsf/gocode/package_ibin.go:152: undefined: io.SeekCurrent
github.com/nsf/gocode/package_ibin.go:214: r.declReader.Reset undefined (type bytes.Reader has no field or method Reset)
查阅相关资料后发现是由于使用
sudo apt-get insall golang-go
命令安装的 go 版本为 go 1.6 , 版本过低导致。 所以需要卸载这个版本再重新安装更新的版本。
wohu@wohu:~/GoCode/src$ sudo apt-get remove golang-go
[sudo] password for wohu:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
golang-1.6-go golang-1.6-race-detector-runtime golang-1.6-src
golang-race-detector-runtime golang-src
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
golang-go
0 upgraded, 0 newly installed, 1 to remove and 6 not upgraded.
After this operation, 48.1 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 286275 files and directories currently installed.)
Removing golang-go (2:1.6-1ubuntu4) ...
Processing triggers for man-db (2.7.5-1) ...
wohu@wohu:~/GoCode/src$ sudo apt-get remove golang-1.6-*
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'golang-1.6-go' for glob 'golang-1.6-*'
Note, selecting 'golang-1.6-doc' for glob 'golang-1.6-*'
Note, selecting 'golang-1.6-race-detector-runtime' for glob 'golang-1.6-*'
Note, selecting 'golang-1.6-src' for glob 'golang-1.6-*'
Package 'golang-1.6-doc' is not installed, so not removed
The following packages will be REMOVED:
golang-1.6-go golang-1.6-race-detector-runtime golang-1.6-src
golang-race-detector-runtime golang-src
0 upgraded, 0 newly installed, 5 to remove and 6 not upgraded.
After this operation, 198 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 286249 files and directories currently installed.)
Removing golang-1.6-go (1.6.1-0ubuntu1) ...
Removing golang-race-detector-runtime (2:1.6-1ubuntu4) ...
Removing golang-1.6-race-detector-runtime (0.0+svn252922-0ubuntu1) ...
dpkg: warning: while removing golang-1.6-race-detector-runtime, directory '/usr/lib/go-1.6/src/runtime/race' not empty so not removed
Removing golang-src (2:1.6-1ubuntu4) ...
Removing golang-1.6-src (1.6.1-0ubuntu1) ...
Go 1.12 安装步骤参考以下链接: