Skip to content

Support go.work file #4721

@didrocks

Description

@didrocks

Welcome

Description of the problem

When detecting the current go version, golangci-lint is using gomoddirective, which does only support go.mod files.

Now that the last supported version of Go is 1.20, I would propose to run go version instead to report correctly the version (including toolchain and environment variable support) to ensure we are less reliant on implementation details.

I’m happy to work on this if the approach seems sound to you.

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version v1.58.1 built with go1.22.3 from (unknown, modified: ?, mod sum: "h1:IYKjkt7nofq/mYXiDUyJiBZQi5kxD0jPCjBy6VXxjz8=") on (unknown)

Configuration

not related to a particular configuration

Go environment

$ go version && go env
go version go1.22.3 linux/amd64
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/didrocks/.cache/go-build'
GOENV='/home/didrocks/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/didrocks/.go/pkg/mod'
GONOPROXY='github.com/canonical/ubuntu-pro-for-wsl'
GONOSUMDB='github.com/canonical/ubuntu-pro-for-wsl'
GOOS='linux'
GOPATH='/home/didrocks/.go'
GOPRIVATE='github.com/canonical/ubuntu-pro-for-wsl'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/didrocks/.go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.3.linux-amd64'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/didrocks/.go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.3.linux-amd64/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.3'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK='/home/didrocks/work/ubuntu-pro-for-wsl/go.work'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1219058700=/tmp/go-build -gno-record-gcc-switches'

Verbose output of running

Not related to a given run

A minimal reproducible example or link to a public repository

Example of a project with go.work and multiple subprojects with go.mod: https://github.com/canonical/ubuntu-pro-for-wsl

Validation

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions