Skip to content

golangci-lint which was installed from Homebrew cannot load a plugin #1182

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

Closed
3 tasks done
tenntenn opened this issue Jun 7, 2020 · 5 comments
Closed
3 tasks done
Labels
bug Something isn't working

Comments

@tenntenn
Copy link

tenntenn commented Jun 7, 2020

Thank you for creating the issue!

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).

Please include the following information:

Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.27.0 built from fb74c2e on 2020-05-13T18:45:55Z
Config file
$ cat .golangci.yml
linters-settings:
  custom:
    called:
      path: /Users/tenntenn/Desktop/example/called.so
      description: called
      original-url: github.com/gostaticanalysis/called
Go environment
$ go version && go env
go version go1.14.4 darwin/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/tenntenn/Library/Caches/go-build"
GOENV="/Users/tenntenn/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/tenntenn/Documents/gopath"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/tenntenn/Desktop/example/go.mod"
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/wm/76fqhrc52ls25p4cmjrjbdqh0000gp/T/go-build134432533=/tmp/go-build -gno-record-gcc-switches -fno-common"
Verbose output of running
$ golangci-lint cache clean
ERRO Unable to load custom analyzer called:/Users/tenntenn/Desktop/example/called.so, plugin: not implemented
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/tenntenn/Desktop/example /Users/tenntenn/Desktop /Users/tenntenn /Users /]
INFO [config_reader] Used config file .golangci.yml
ERRO Unable to load custom analyzer called:/Users/tenntenn/Desktop/example/called.so, plugin: not implemented
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck]
INFO [loader] Go packages loading at mode 575 (compiled_files|deps|imports|name|exports_file|files|types_sizes) took 525.274151ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 319.206µs
INFO [linters context/goanalysis] analyzers took 2.898776605s with top 10 stages: buildir: 2.040732182s, inspect: 216.088362ms, fact_purity: 181.508378ms, fact_deprecated: 169.971254ms, printf: 145.820126ms, ctrlflow: 138.675668ms, S1039: 425.535µs, errcheck: 396.659µs, varcheck: 331.239µs, ineffassign: 317.106µs
INFO [linters context/goanalysis] analyzers took 6.437469ms with top 10 stages: buildir: 6.075381ms, U1000: 362.088µs
INFO [runner] processing took 5.112µs with stages: max_same_issues: 2.611µs, skip_dirs: 364ns, max_from_linter: 284ns, nolint: 212ns, cgo: 180ns, autogenerated_exclude: 179ns, filename_unadjuster: 175ns, skip_files: 162ns, diff: 162ns, path_prettifier: 157ns, identifier_marker: 156ns, max_per_file_from_linter: 87ns, exclude: 81ns, path_shortener: 78ns, source_code: 77ns, uniq_by_line: 76ns, exclude-rules: 71ns
INFO [runner] linters took 3.306357851s with stages: goanalysis_metalinter: 3.210039278s, unused: 96.266069ms
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 40 samples, avg is 143.9MB, max is 204.4MB
INFO Execution took 3.86492438s

I had installed golangci-lint via brew as below.

$ brew install golangci/tap/golangci-lint

The binary of golangci-lint cannot load a private linter via a plugin.
I think the binary had been built with CGO_ENABLED=0.
When CGO_ENABLED had set 0, plugin package does not work.

@tenntenn tenntenn added the bug Something isn't working label Jun 7, 2020
@boring-cyborg
Copy link

boring-cyborg bot commented Jun 7, 2020

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@dbraley
Copy link
Contributor

dbraley commented Jun 11, 2020

Can confirm, this doesn't work for the reason @tenntenn stated. Unfortunately, it seems like that flag is required to build some of the linux executables. I don't know enough about goreleaser configuration at the moment to propose a way to fix this for as many distributions as possible without breaking the rest - and I'm not sure if that would even be a desirable state to be in?

I will say, my company has been using it without a problem just by fetching the git repo and building locally. It's not the recommended way, obviously, but it has worked reasonably well for us for the past 6 months or so.

@tenntenn
Copy link
Author

Thank you for confirming the issue.

I understood that the CGO_ENABLED cannot change for building of some Linux distributions.

I think improve the issue by adding a note of it on the document.

@iwankgb
Copy link
Contributor

iwankgb commented Jul 4, 2020

All the goreleaser builds have CGO_ENABLED=0 set:

- CGO_ENABLED=0
. I think that @dbraley's suggestion to build your own binary is the best approach.

@iwankgb
Copy link
Contributor

iwankgb commented Jul 4, 2020

We could try to use clang to help with cgo and cross compilation but it will still cause issues (e.g. on alpine that does not use glibc but musl) so I believe that, for portability purposes, all builds distributed on Github must use CGO_ENABLED=0.

@tenntenn, while I do understand your problem I don't think we can help a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants