Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot go get staticcheck #653

Closed
axcdnt opened this issue Nov 12, 2019 · 3 comments
Closed

Cannot go get staticcheck #653

axcdnt opened this issue Nov 12, 2019 · 3 comments
Labels
invalid User error and other non-issues

Comments

@axcdnt
Copy link

axcdnt commented Nov 12, 2019

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"
@axcdnt axcdnt added bug needs-triage Newly filed issue that needs triage labels Nov 12, 2019
@dominikh
Copy link
Owner

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.

@dominikh dominikh added waiting-for-feedback Waiting for the user to get back to us and removed bug needs-triage Newly filed issue that needs triage labels Nov 12, 2019
@ndabAP
Copy link

ndabAP commented Nov 12, 2019

I had the same problem and fixed it setting module mode to on:

go env -w GO111MODULE=on

@axcdnt
Copy link
Author

axcdnt commented Nov 12, 2019

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.

@dominikh dominikh added invalid User error and other non-issues and removed waiting-for-feedback Waiting for the user to get back to us labels Oct 17, 2021
nars1 pushed a commit to YottaDB/YDBGo that referenced this issue Mar 13, 2024
…O111MODULE=off

**Problem**

After bump YDBGo wrapper version to odd development version v1.2.5 in YDBGo!185, Daily pipeline failed with this error.
```shell
$ go get -u golang.org/x/lint/golint
345# golang.org/x/tools/go/types/objectpath
346/go/src/golang.org/x/tools/go/types/objectpath/objectpath.go:397:10: meth.Origin undefined (type *types.Func has no field or method Origin)
```

**Cause**

The cause of this problem likely to be `GO111MODULE=off` (Reference : dominikh/go-tools#653, #47).
From the reference GO111MODULE=off might have some problem with linter.

**Solution**

Change `GO111MODULE=off` to `GO111MODULE=on` but in only lint_code section to reduce impact to the whole pipeline.
But after `GO111MODULE=on` some change need to be apply here because we're using Go module.

After some research, `go get -u golang.org/x/lint/golint` need to change to `go install golang.org/x/lint/golint@latest`.

`go get` when `GO111MODULE=off` will download source package and compiled it to a binary but `GO111MODULE=on`, it won't.
So, `go install` would be a solution because it will download source code and compile it to binary as we want.
(Reference : https://medium.com/@chaewonkong/difference-between-go-get-and-go-install-in-go-a076d7352186)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid User error and other non-issues
Projects
None yet
Development

No branches or pull requests

3 participants