bazel-contrib / bazel-contrib/rules_go

nogo not populating Go version in analysis pass

Open
#3,924 5 comments 4 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1.5k
Forks
760
Avg merge
1d 11h
Merged PRs (30d)
12

Description

### What version of rules_go are you using?

0.46.0

### What version of gazelle are you using?

0.36.0

### What version of Bazel are you using?

7.1.1

### Does this issue reproduce with the latest releases of all the above?

Yes

### What operating system and processor architecture are you using?

macOS (arm64)

### Any other potentially useful information about your toolchain?

No

### What did you do?

I ran nogo with Go version 1.22.

### What did you expect to see?

No linting errors.

### What did you see instead?

Linting errors from the `loopclosure` linter.

The `loopclosure` linter detects the Go version and [disables itself for Go 1.22 and later](https://github.com/golang/tools/blob/v0.20.0/go/analysis/passes/loopclosure/loopclosure.go#L57-L59). For this, it checks `pass.TypesInfo.FileVersions`, but [this field does not appear to be populated by nogo](https://github.com/bazelbuild/rules_go/blob/v0.46.0/go/tools/builders/nogo_main.go#L382-L389).

Contributor guide

Open the contributing guide

Research direction

Inspect go/tools/builders/nogo_main.go around lines 382-389 and compare how the loopclosure analyzer uses pass.TypesInfo.FileVersions. Reproduce the reported nogo run with Go 1.22, then verify that the analysis pass receives the version information and no longer reports loopclosure errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.