chore: fix data race (#1593)

This commit is contained in:
Kevin Wan
2022-02-28 23:17:51 +08:00
committed by GitHub
parent cf7c7cb392
commit 259a5a13e7
8 changed files with 40 additions and 37 deletions

View File

@@ -3,6 +3,7 @@ package logx
import (
"log"
"strings"
"sync/atomic"
"testing"
"time"
@@ -38,10 +39,10 @@ func TestWithDurationInfo(t *testing.T) {
}
func TestWithDurationInfoConsole(t *testing.T) {
old := encoding
encoding = plainEncodingType
old := atomic.LoadUint32(&encoding)
atomic.StoreUint32(&encoding, plainEncodingType)
defer func() {
encoding = old
atomic.StoreUint32(&encoding, old)
}()
var builder strings.Builder