mirror of https://github.com/golang/go.git
log/slog: fix check for nil prefix
Previously, handleState.prefix was nil if and only if the length of the prefix was zero. Now, prefix is never nil. Fix the nil check in the code by also checking if the length is non-zero. Change-Id: I9f69c0029cb1c73fe6c2919c78fee7d4085bfd85 Reviewed-on: https://go-review.googlesource.com/c/go/+/495977 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
bc96901e89
commit
2f1e643229
|
|
@ -469,7 +469,7 @@ func (s *handleState) appendError(err error) {
|
|||
|
||||
func (s *handleState) appendKey(key string) {
|
||||
s.buf.WriteString(s.sep)
|
||||
if s.prefix != nil {
|
||||
if s.prefix != nil && len(*s.prefix) > 0 {
|
||||
// TODO: optimize by avoiding allocation.
|
||||
s.appendString(string(*s.prefix) + key)
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue