From d06f545cc995628c14cfaa55c879c586f0934363 Mon Sep 17 00:00:00 2001 From: raina Date: Thu, 7 Mar 2024 17:18:18 +0800 Subject: [PATCH] fix: lint --- gin/panic_recovery.go | 3 +-- log/async_file_writer_test.go | 5 ++--- log/internal/zap/json_encoder.go | 6 +----- log/internal/zap/logger.go | 2 +- log/logger_test.go | 5 ++--- node/validator.go | 1 - 6 files changed, 7 insertions(+), 15 deletions(-) diff --git a/gin/panic_recovery.go b/gin/panic_recovery.go index 10ce230..0edecd3 100644 --- a/gin/panic_recovery.go +++ b/gin/panic_recovery.go @@ -3,7 +3,6 @@ package middlewares import ( "bytes" "fmt" - "io/ioutil" "log" "net" "net/http" @@ -83,7 +82,7 @@ func stack(skip int) []byte { // Print this much at least. If we can't find the source, it won't show. fmt.Fprintf(buf, "%s:%d (0x%x)\n", file, line, pc) if file != lastFile { - data, err := ioutil.ReadFile(file) + data, err := os.ReadFile(file) if err != nil { continue } diff --git a/log/async_file_writer_test.go b/log/async_file_writer_test.go index 5b85a2d..65d2a1d 100644 --- a/log/async_file_writer_test.go +++ b/log/async_file_writer_test.go @@ -1,7 +1,6 @@ package log import ( - "io/ioutil" "os" "strings" "testing" @@ -12,12 +11,12 @@ func TestWriter(t *testing.T) { w.Write([]byte("hello\n")) w.Write([]byte("world\n")) w.Stop() - files, _ := ioutil.ReadDir("./") + files, _ := os.ReadDir("./") for _, f := range files { fn := f.Name() if strings.HasPrefix(fn, "hello") { t.Log(fn) - content, _ := ioutil.ReadFile(fn) + content, _ := os.ReadFile(fn) t.Log(string(content)) os.Remove(fn) } diff --git a/log/internal/zap/json_encoder.go b/log/internal/zap/json_encoder.go index d586494..11b2a84 100644 --- a/log/internal/zap/json_encoder.go +++ b/log/internal/zap/json_encoder.go @@ -198,7 +198,7 @@ func (enc *zapJsonEncoder) AppendByteString(val []byte) { func (enc *zapJsonEncoder) AppendComplex128(val complex128) { enc.addElementSeparator() // Cast to a platform-independent, fixed-size type. - r, i := float64(real(val)), float64(imag(val)) + r, i := real(val), imag(val) enc.buf.AppendByte('"') // Because we're always in a quoted string, we can use strconv without // special-casing NaN and +/-Inf. @@ -386,10 +386,6 @@ func (enc *zapJsonEncoder) EncodeEntry(ent zapcore.Entry, fields []zapcore.Field return ret, nil } -func (enc *zapJsonEncoder) truncate() { - enc.buf.Reset() -} - func (enc *zapJsonEncoder) closeOpenNamespaces() { for i := 0; i < enc.openNamespaces; i++ { enc.buf.AppendByte('}') diff --git a/log/internal/zap/logger.go b/log/internal/zap/logger.go index ff9cd2f..0d692d2 100644 --- a/log/internal/zap/logger.go +++ b/log/internal/zap/logger.go @@ -309,8 +309,8 @@ func (zl *logger) sweetenFields(args []interface{}, skipCaller int) []zap.Field usedFields[keyStr] += 1 if usedFields[keyStr] > 1 { keyStr += strconv.Itoa(usedFields[keyStr]) - } + fields = append(fields, zap.Any(keyStr, val)) } i += 2 diff --git a/log/logger_test.go b/log/logger_test.go index 968b773..81b3580 100644 --- a/log/logger_test.go +++ b/log/logger_test.go @@ -2,7 +2,6 @@ package log_test import ( "context" - "io/ioutil" "os" "strings" "testing" @@ -18,12 +17,12 @@ func initTestLogger(lvl types.Level) { func printLogContent(t *testing.T) { log.Stop() - files, _ := ioutil.ReadDir("./tmp") + files, _ := os.ReadDir("./tmp") for _, f := range files { fn := f.Name() if strings.HasPrefix(fn, "test") { t.Log(fn) - content, _ := ioutil.ReadFile("./tmp/" + fn) + content, _ := os.ReadFile("./tmp/" + fn) t.Log(string(content)) } } diff --git a/node/validator.go b/node/validator.go index ea0a5b4..368e42e 100644 --- a/node/validator.go +++ b/node/validator.go @@ -78,7 +78,6 @@ type validator struct { client *ethclient.Client scheduler *gocron.Scheduler - chainID *big.Int mevRunning bool }