Skip to content

Version string different between go install and using the install.sh script #5069

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
6 of 7 tasks
systay opened this issue Oct 16, 2024 · 5 comments
Closed
6 of 7 tasks
Labels
area: install Issue relates to installation or downloading process question Further information is requested

Comments

@systay
Copy link

systay commented Oct 16, 2024

Welcome

  • Yes, I'm using a binary release within 2 latest releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've read the typecheck section of the FAQ.
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.).
  • I agree to follow this project's Code of Conduct

Description of the problem

Installing golangci-lint using two different methods leads to different results when doing golangci-lint version.
Here is my little script showing the issue:

> curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0                                        1 ↵
golangci/golangci-lint info checking GitHub for tag 'v1.61.0'
golangci/golangci-lint info found version: 1.61.0 for v1.61.0/darwin/arm64
golangci/golangci-lint info installed /Users/systay/.gvm/pkgsets/go1.22.7/global/bin/golangci-lint

> golangci-lint --version                                                                                                            
golangci-lint has version 1.61.0 built with go1.23.1 from a1d6c560 on 2024-09-09T17:44:42Z
> go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint has version v1.61.0 built with go1.22.7 from (unknown, modified: ?, mod sum: "h1:VvbOLaRVWmyxCnUIMTbf1kDsaJbTzH20FAMXTAlQGu8=") on (unknown)

Notice that one returns 1.61.0 and the other returns v1.61.0

Version of golangci-lint

n/a

Configuration

n/a

Go environment

go version go1.23.1 darwin/arm64
GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/systay/Library/Caches/go-build'
GOENV='/Users/systay/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/systay/.gvm/pkgsets/go1.23.1/global/pkg/mod'
GONOPROXY='github.com/planetscale/*'
GONOSUMDB='github.com/planetscale/*'
GOOS='darwin'
GOPATH='/Users/systay/.gvm/pkgsets/go1.23.1/global'
GOPRIVATE='github.com/planetscale/*'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/systay/.gvm/gos/go1.23.1'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/systay/.gvm/gos/go1.23.1/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.1'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/systay/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/19/j1137q8s6tb3syp_3g6cjqq40000gn/T/go-build2277648204=/tmp/go-build -gno-record-gcc-switches -fno-common'

Verbose output of running

n/a

A minimal reproducible example or link to a public repository

I think my description should be enough

Validation

  • Yes, I've included all information above (version, config, etc.).

Supporter

@systay systay added the bug Something isn't working label Oct 16, 2024
Copy link

boring-cyborg bot commented Oct 16, 2024

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

@ldez ldez added question Further information is requested and removed bug Something isn't working labels Oct 16, 2024
@ldez
Copy link
Member

ldez commented Oct 16, 2024

Hello,

When using the install script, you download a golangci-lint binary from the releases.

When using go install, you compile the golangci-lint sources locally.

So the difference in the version details is expected.

Duplicate of #3789

@ldez ldez closed this as completed Oct 16, 2024
@systay
Copy link
Author

systay commented Oct 16, 2024

Thank you for the explanation.

However, I’m still unsure why there is a difference in the output, specifically why one installation method includes the v prefix in the version number (i.e., v1.61.0), while the other doesn’t (i.e., 1.61.0). I would expect the version formatting to remain consistent regardless of whether it’s installed from a release or compiled locally. Could you clarify if this is intentional behavior or if I’m missing something?

@ldez
Copy link
Member

ldez commented Oct 16, 2024

The version comes from a value sets during the compilation:

As the documentation explains, local compilation is not recommended because it has side effects.

Based on that, I don't see this difference as a "bug".

We cannot just strip the letter v (because the version can be a hash), and we cannot control how go install uses the module version.

If we want to change this, there are only 2 possibilities:

  1. Use .Tag instead of .Version inside the goreleaser configuration.
  2. Use a regular expression to detect and strip v.

The possibility 1 can be seen as a breaking change, so it's not an acceptable approach.

The possibility 2 seems overkill to just handle a version when using a not recommended way to install golangci-lint. And this may also be seen as a breaking change.

@systay
Copy link
Author

systay commented Oct 16, 2024

Thank you for the explanation. Makes sense. Appreciate it.

@ldez ldez added the area: install Issue relates to installation or downloading process label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: install Issue relates to installation or downloading process question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants