Skip to content

Commit 7ceff13

Browse files
committed
go/analysis/passes/structtag: ignore findings for "encoding/..."
Don't warn on structtag findings for any of the new packages added as part of the json v2 project. Just skip all of "encoding/..." on the theory that if anything in std is using invalid tags, it has a good reason. Change-Id: Ie9fbbe9ef1be7ea574c74824a26951501f6c5e2d Reviewed-on: https://go-review.googlesource.com/c/tools/+/665055 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
1 parent d363f10 commit 7ceff13

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

go/analysis/passes/structtag/structtag.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ var checkTagSpaces = map[string]bool{"json": true, "xml": true, "asn1": true}
8989

9090
// checkCanonicalFieldTag checks a single struct field tag.
9191
func checkCanonicalFieldTag(pass *analysis.Pass, field *types.Var, tag string, seen *namesSeen) {
92-
switch pass.Pkg.Path() {
93-
case "encoding/json", "encoding/json/v2", "encoding/xml":
92+
if strings.HasPrefix(pass.Pkg.Path(), "encoding/") {
9493
// These packages know how to use their own APIs.
9594
// Sometimes they are testing what happens to incorrect programs.
9695
return

0 commit comments

Comments
 (0)