From 111ab754324e5d5646f84354bc1a134907baaa49 Mon Sep 17 00:00:00 2001 From: Mateusz Poliwczak Date: Fri, 25 Aug 2023 16:42:42 +0000 Subject: [PATCH] log/slog: use atomic.Pointer instead of atomic.Value There is no need to use atomic.Value, atomic.Pointer should also be more performant here. Change-Id: I04cc1befbe1112665a9d9e16197ea3caef5e5fa3 GitHub-Last-Rev: 577902519ff744c936c5e707802f66aeae32c760 GitHub-Pull-Request: golang/go#62288 Reviewed-on: https://go-review.googlesource.com/c/go/+/523035 TryBot-Result: Gopher Robot LUCI-TryBot-Result: Go LUCI Reviewed-by: Alan Donovan Reviewed-by: Jonathan Amsterdam Run-TryBot: Mateusz Poliwczak --- src/log/slog/logger.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/log/slog/logger.go b/src/log/slog/logger.go index a068085f47c..a42b0a4bccc 100644 --- a/src/log/slog/logger.go +++ b/src/log/slog/logger.go @@ -14,14 +14,14 @@ import ( "time" ) -var defaultLogger atomic.Value +var defaultLogger atomic.Pointer[Logger] func init() { defaultLogger.Store(New(newDefaultHandler(loginternal.DefaultOutput))) } // Default returns the default Logger. -func Default() *Logger { return defaultLogger.Load().(*Logger) } +func Default() *Logger { return defaultLogger.Load() } // SetDefault makes l the default Logger. // After this call, output from the log package's default Logger