Browse Source

build: update goctl dependency ddl-parser to v1.0.3 (#1586)

* build: update goctl dependency ddl-parser to v1.0.3

* fix: race condition when testing logx

Resolves: #1587
Fyn 3 năm trước cách đây
mục cha
commit
cf7c7cb392
3 tập tin đã thay đổi với 10 bổ sung6 xóa
  1. 7 3
      core/logx/logs.go
  2. 2 2
      core/logx/tracelogger_test.go
  3. 1 1
      tools/goctl/go.mod

+ 7 - 3
core/logx/logs.go

@@ -33,7 +33,7 @@ const (
 )
 
 const (
-	jsonEncodingType = iota
+	jsonEncodingType uint32 = iota
 	plainEncodingType
 
 	jsonEncoding     = "json"
@@ -137,9 +137,9 @@ func SetUp(c LogConf) error {
 	}
 	switch c.Encoding {
 	case plainEncoding:
-		encoding = plainEncodingType
+		setEncoding(plainEncodingType)
 	default:
-		encoding = jsonEncodingType
+		setEncoding(jsonEncodingType)
 	}
 
 	switch c.Mode {
@@ -666,3 +666,7 @@ func (lw logWriter) Write(data []byte) (int, error) {
 	lw.logger.Print(string(data))
 	return len(data), nil
 }
+
+func setEncoding(encodingType uint32) {
+	atomic.StoreUint32(&encoding, encodingType)
+}

+ 2 - 2
core/logx/tracelogger_test.go

@@ -84,9 +84,9 @@ func TestTraceInfo(t *testing.T) {
 
 func TestTraceInfoConsole(t *testing.T) {
 	old := encoding
-	encoding = plainEncodingType
+	setEncoding(jsonEncodingType)
 	defer func() {
-		encoding = old
+		setEncoding(old)
 	}()
 
 	var buf mockWriter

+ 1 - 1
tools/goctl/go.mod

@@ -12,6 +12,6 @@ require (
 	github.com/stretchr/testify v1.7.0
 	github.com/urfave/cli v1.22.5
 	github.com/zeromicro/antlr v0.0.1
-	github.com/zeromicro/ddl-parser v1.0.2
+	github.com/zeromicro/ddl-parser v1.0.3
 	github.com/zeromicro/go-zero v1.3.0
 )