install golang.org/x/tools/cmd/guru error - go

I have a issue of go get golang.org/x/tools/cmd/guru
When update my go tools in vscode IDE.But golang.org/x/tools/cmd/guru package always shows the following install error
error:
golang.org/x/tools/go/internal/gcimporter
src/golang.org/x/tools/go/internal/gcimporter/bexport.go:212: obj.IsAlias undefined (type *types.TypeName has no field or method IsAlias)
go version is 1.8.7

You are going to have to upgrade go. The language added a concept called aliases. The reflection package therefore has to know about them and apparently guru. You should try and stay up to date, as the Go team only supports the last two versions.
As of today, 1.11.4 is the latest: https://golang.org/dl/

Related

Chaosmonkey Go Package Install

I have been trying to install chaosmonkey following the instruction from here using go
However, I have not been able to successfully resolve the issue for the past day. I keep getting the below error and if I try installing other packages using go get, it install it without any issue so I believe my path is correct.
go: downloading github.com/netflix/chaosmonkey v2.0.2+incompatible
go get: module github.com/netflix/chaosmonkey#v2.0.2 found (v2.0.2+incompatible), but does not contain package github.com/netflix/chaosmonkey/cmd/chaosmonkey
There is not much information on the internet and any help would be appreciated!

Unknown subcommand "mod" error while running go mod init

I have installed the go language in my ubuntu using sudo apt install golang-go.
It was successfully installed. When i run go version I am getting go version go1.10.4 linux/amd64
but when i tried running go mod init projectName I am getting the following error go: unknown subcommand "mod"
Do I need to install mod package or am i missing something? I have implemented the solution given by christophe in this forum but it didn't work for me.
Preliminary module support was added in Go 1.11, so Go 1.10 knows no mod subcommand.
You need to install a newer, preferably the newest 1.14 version of Go. Get it from the official downloads page. Go 1.10 is not even supported anymore (doesn't receive security patches).
The prepared packages of OSes usually lag behind new releases. I'd advise to always get Go from the official page.
Because preliminary support for go-modules came in version 1.11 and 1.12.
More here
I suggest that you install using the linux build directly from golang

Can't install any GoLang script in Linux

When I try to run any Go script it show me this error
I installed go lang step by step from this link
https://www.tecmint.com/install-go-in-linux/
When I setup go script like this
go get github.com/tomnomnom/waybackurls
I got error like this
github.com/tomnomnom/waybackurls
src/github.com/tomnomnom/waybackurls/main.go:191: u.Hostname undefined
(type *url.URL has no field or method Hostname)
If you are following the guide you linked by copy-pasting commands, you will have installed Go 1.7.3. The function url.Hostname() was added in Go 1.8.
I suggest completely ignoring that guide. Remove /usr/local/go, remove ~/go_projects and undo the path related stuff.
Instead, use the package manager of your OS to install Go.
Most likely, this means you should do either sudo apt install golang (for Ubuntu, Debian, ...) or sudo dnf install golang (Fedora, CentOS, ...).
That will give you the latest version that is supported by distro maintainer (which at the moment is probably 1.11 or 1.12, depending on your distro).
As an alternative to the packagemanager, download the latest version from https://golang.org/dl/.
This approach also gives you an installation that follows the Go ecosystem their conventions for paths (I'm not sure if ~/go_projects was ever a think, but it isn't today).

How to Install old version go-vim plugin

I am a new golang developer. My company uses go 1.10.2, and I hit following error during installing vim-go
Error installing golang.org/x/tools/cmd/gopls: # golang.org/x/tools/internal/lsp/source^#../../../golang.org/x/tools/internal/lsp/source/symbols.go:232:18: ti.EmbeddedType undefined (t
ype *types.Interface has no field or method EmbeddedType
It turns out due to the old go version. https://github.com/fatih/vim-go/issues/2246, https://github.com/golang/go/issues/31864. Since upgrade go version is not an option, the only choice I can think of is to install an old version vim-go that supports go 1.10.2. But I am not sure how to do so.
This is how I install vim-go now:
git clone https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go
then open up vim and run :GoInstallBinaries (where above error show up)
Any suggestions would be great. Since I am neither a vim nor a go person before, more details would be appreciate!
You should try goenv it support multiple version of golang.
Here is the installation guide
https://github.com/syndbg/goenv/blob/master/INSTALL.md
And after installation you can choose and install any version from the list.
Just by typing..
goenv install 1.10.2
Solved it by cloning the repo and checkout to an old commit

import object is expected between different go versions

I switched from go 1.6 to 1.4.2 for faster compilation. When I recompile the earlier compiled binary of 1.6, I get the following error:
import go/pkg/darwin_amd64/github.com/Sirupsen/logrus.a: object is
[darwin amd64 go1.6 X:none] expected [darwin amd64 go1.4.2 X:precisestack]
I have already tried go build -a - which works without any error. And have also tried go install -a and go build - both of these commands throw the above mentioned error.
I already know that, if I delete by go/pkg folder, then it will work. That is the answer of the already existing SO question
I wanted to know, if there is another way to resolve this using go tools, other than deleting the pkg folder.
Most likely due to previous compiles. Just delete your $GOLANG/pkg and you are good to go!
another way to resolve this using go tools, other than deleting the pkg folder.
The go tool chain is unlikely to be modified to handle this corner use case.

Resources