analyzer: a //go:build ignore generator file turns surplus off for its package
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 83/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- go
- 领域
- testing-qa, tooling
调研方向
从 internal/surplus.go:225 开始,将分析器对忽略文件的检查与 shrink 已采用的区分方式进行比较。使用标记为 //go:build ignore 和 package main 的 gen.go 文件复现该行为,然后运行分析器的相关测试或独立驱动程序。完成标准是:即使存在这个额外文件,分析器仍会报告不需要的共享声明,包括通过 go vet -vettool 运行时。
由索引模型根据 Issue 内容生成。
描述
len(pass.IgnoredFiles) > 0 (internal/surplus.go:225) switches the rule off for any build-excluded file. That includes the common gen.go written as //go:build ignore plus package main. unseen() already skips files of another package and reads excluded .go files of the same package by name, so this check only needs to cover files that are not Go. shrink already makes that distinction, so the analyzer and shrink disagree here.
Reproduction
A package with one unneeded //declscope:shared func helper():
| Package | Result |
|---|---|
| Without an extra file | //declscope:shared on helper: no use from another namespace is visible to declscope, exit 3 |
With gen.go (//go:build ignore, package main) |
No output, exit 0. The same under the standalone driver and under go vet -vettool |
Suggested fix
len(pass.OtherFiles) > 0 || slices.ContainsFunc(pass.IgnoredFiles, func(f string) bool { return !strings.HasSuffix(f, ".go") })
- 主要语言
- Go
- 星标
- 42
- 派生
- 1
- 平均合并
- 57 分钟
- 30 天内合并 PR
- 135
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
相似的 Issue
-
[Bug]: ap gateway image build cannot find local policies on Windows可能已有人在做 @Jayzilva 今天认领。 未关闭Aspect/Configuration Severity/Major
难度 2/5 1-3 小时 新手友好度 83/100
wso2/api-platform#3912 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
keyxmakerx/Chronicle#1721 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
Gentleman-Programming/gentle-ai#5720 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
ClickHouse/ch-go#1218 ·
维护者通常 13 天内回复