aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2023-05-09 20:56:09 -0400
committerJonathan Amsterdam <jba@google.com>2023-05-16 18:01:59 +0000
commit6fc5e7d4b52986f82ec25d5993ff7f8bde8b61f5 (patch)
tree929e29615ceea641a871734fff310659079f3e7d /test/codegen
parenta3e95f3b509e59a814bbc8073664d46739869e2e (diff)
downloadgo-6fc5e7d4b52986f82ec25d5993ff7f8bde8b61f5.tar.xz
log/slog: create prefix buffer earlier
It's possible that the replacement for a built-in attribute is a Group. That would cause a nil pointer exception because the handleState.prefix field isn't set until later, in appendNonBuiltIns. So create the prefix field earlier, at the start of commonHandler.handle. Once we do this, we can simplify the code by creating and freeing the prefix in newHandleState. Along the way I discovered a line that wasn't being tested: state.prefix.WriteString(h.groupPrefix) so I modified an existing test case to cover it. Change-Id: Ib385e3c13451017cb093389fd5a1647d53e610bf Reviewed-on: https://go-review.googlesource.com/c/go/+/494037 Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'test/codegen')
0 files changed, 0 insertions, 0 deletions