When I run go get it returns the following error:
â–¶ go get honnef.co/go/tools/cmd/staticcheck
# honnef.co/go/tools/lint
../../../go/src/honnef.co/go/tools/lint/runner.go:318:21: d.Related undefined (type analysis.Diagnostic has no field or method Related)
go version: go version go1.13.3 darwin/amd64
go env:
â–¶ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="<home>/Library/Caches/go-build"
GOENV="<home>/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY="<repos>"
GONOSUMDB="<repos>"
GOOS="darwin"
GOPATH="<home>/go"
GOPRIVATE="<repos>"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="<home>/.asdf/installs/golang/1.13.3/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="<home>/.asdf/installs/golang/1.13.3/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/1w/vl4qj_2s2kq7vjlhvrvchdwm0000gp/T/go-build813390475=/tmp/go-build -gno-record-gcc-switches -fno-common"
If you're working in GOPATH mode, either use go get -u or manually update your version of golang.org/x/tools to at least revision 774d2ec196ee.
If you're working in module mode, this shouldn't be happening, unless you're somehow forcing an older version of golang.org/x/tools, in which case don't do that.
I had the same problem and fixed it setting module mode to on:
go env -w GO111MODULE=on
Thanks for the feedback. In my mind, GO111MODULE was on by default for Go 1.13+, but this issue proves me wrong. @ndabAP suggestion made it work.
Most helpful comment
I had the same problem and fixed it setting module mode to
on: