shellgolintergolangci-lint

Can't install golangci-lint locally


I'm using RHEL 8.6 and my Go version is the following:

$ go version
go version go1.18.3 linux/amd64

I'm trying to install locally golangci-lint and none of the described ways in the documentation are working.

What I tried:

First:

$ curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.2
golangci/golangci-lint info checking GitHub for tag 'v1.46.2'
golangci/golangci-lint info found version: 1.46.2 for v1.46.2/linux/amd64
golangci/golangci-lint info installed /home/acabista/go/bin/golangci-lint
$ golangci-lint --version
bash: golangci-lint: command not found...

Second:

$ go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.2
$ golangci-lint --version
bash: golangci-lint: command not found...

Am I missing a step? How can I make this local installation work?


Solution

  • If golang-ci has properly been installed, the issue is most likely that the installation directory is not in your PATH environment variable. Calling golang-ci this way should then work:

    ${GOPATH}/bin/golangci-lint --version
    

    or

    /home/acabista/go/bin/golangci-lint --version
    

    To chek what is happening exactly you can check the content of the GOPATH environment variable. Its content defines where binaries are installed when a go install like command is run.

    echo $GOPATH
    

    You need to check also what is the content of the PATH variable, this one defines in which directory the shell looks for binary to execute:

    echo $PATH