Skip to content

Commit 8b4b27b

Browse files
committed
go/analysis/passes/slog: fix Group kv offset
The first argument to Group is a key, so its value in the kvFuncs map should be 1, not zero. The test was also calling Group wrong. Change-Id: Iafb176b361d5fdc50c28cffe46f49dea29553c63 Reviewed-on: https://go-review.googlesource.com/c/tools/+/495976 Reviewed-by: Alan Donovan <[email protected]> Run-TryBot: Jonathan Amsterdam <[email protected]> TryBot-Result: Gopher Robot <[email protected]> gopls-CI: kokoro <[email protected]>
1 parent 242e5ed commit 8b4b27b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

go/analysis/passes/slog/slog.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ var kvFuncs = map[string]map[string]int{
204204
"WarnCtx": 2,
205205
"ErrorCtx": 2,
206206
"Log": 3,
207-
"Group": 0,
207+
"Group": 1,
208208
},
209209
"Logger": map[string]int{
210210
"Debug": 1,

go/analysis/passes/slog/testdata/src/a/a.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ func All() {
143143

144144
r.Add(1, 2) // want `slog.Record.Add arg "1" should be a string or a slog.Attr`
145145

146-
_ = slog.Group("a", 1, 2, 3) // want `slog.Group arg "2" should be a string or a slog.Attr`
146+
_ = slog.Group("key", "a", 1, "b", 2)
147+
_ = slog.Group("key", "a", 1, 2, 3) // want `slog.Group arg "2" should be a string or a slog.Attr`
147148

148149
}
149150

0 commit comments

Comments
 (0)