]> Cypherpunks repositories - gostls13.git/commit
log/slog: don't call SetDefault in examples
authorJonathan Amsterdam <jba@google.com>
Wed, 5 Apr 2023 10:13:17 +0000 (06:13 -0400)
committerJonathan Amsterdam <jba@google.com>
Wed, 12 Apr 2023 19:35:47 +0000 (19:35 +0000)
commit6116a47800b4e2aa477702b415752995a3156b26
tree03be06881357e2d1a0de783dbc66f4c4ed827c36
parent89567a35c11c343cf765d6fb1270e1250e50d83f
log/slog: don't call SetDefault in examples

Replace the default Logger in some examples with a locally constructed
Logger.

Calling SetDefault changes global state that could affect other tests.
Although we could use a defer to restore the state, that clutters
the example and would not work if tests were run concurrently.

Change-Id: Ib2595c57f8e6c3e0b39b982f682ba287c2ae249d
Reviewed-on: https://go-review.googlesource.com/c/go/+/482475
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
src/log/slog/example_test.go
src/log/slog/example_wrap_test.go