Can't install golangci-lint locally
Asked Answered
T

4

5

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/[email protected]
$ golangci-lint --version
bash: golangci-lint: command not found...

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

Tanny answered 8/7, 2022 at 12:55 Comment(0)
L
9

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
Linage answered 8/7, 2022 at 13:26 Comment(0)
I
4

I had similar problem installing golangci-lint. I resolved it by adding this PATH=$PATH:$(go env GOPATH)/bin/ to my ~/.bashrc file and run source ~/.bashrc on the terminal.

To verify, check the version by running the command from terminal golangci-lint --version

Reference: Found the solution from this github discussion here

Ida answered 23/1 at 2:38 Comment(0)
K
1
sudo snap install golangci-lint 

This works for me

Khaki answered 10/10, 2023 at 13:56 Comment(0)
R
0

Install it this way to avoid error

curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b $(go env GOPATH)/bin v1.54.0
Roasting answered 10/8, 2023 at 10:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.