diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-03-14 12:18:42 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-03-14 12:18:42 +0100 |
commit | 0fbab7cbc5a0b57ec875858111b178160d18acb5 (patch) | |
tree | ac718d00f98bf7df0cef4d82d3e8db527f85560d /common | |
parent | f5eddf89bf6c8ea9571c16f301f6b449259e6187 (diff) |
commands: Fix data race in test
Note that this is a test fix only.
Diffstat (limited to 'common')
-rw-r--r-- | common/loggers/loggers.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/common/loggers/loggers.go b/common/loggers/loggers.go index 824fe18bd..fbbbca435 100644 --- a/common/loggers/loggers.go +++ b/common/loggers/loggers.go @@ -21,6 +21,7 @@ import ( "os" "regexp" "runtime" + "sync/atomic" "time" "github.com/gohugoio/hugo/common/terminal" @@ -31,7 +32,7 @@ import ( var ( // Counts ERROR logs to the global jww logger. GlobalErrorCounter *jww.Counter - PanicOnWarning bool + PanicOnWarning atomic.Bool ) func init() { @@ -136,14 +137,14 @@ const panicOnWarningMessage = "Warning trapped. Remove the --panicOnWarning flag func (l *logger) Warnf(format string, v ...any) { l.WARN.Printf(format, v...) - if PanicOnWarning { + if PanicOnWarning.Load() { panic(panicOnWarningMessage) } } func (l *logger) Warnln(v ...any) { l.WARN.Println(v...) - if PanicOnWarning { + if PanicOnWarning.Load() { panic(panicOnWarningMessage) } } |