Repository: zeromicro/go-zero
Pull request #3989 (2024-03-08 14:25:46)

chore: fix warnings

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/zeromicro/go-zero/pull/3989?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeromicro) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 95.21%. Comparing base [(`2629636`)](https://app.codecov.io/gh/zeromicro/go-zero/commit/2629636f648bd829f5643c63b5359292be565eac?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeromicro) to head [(`acffe12`)](https://app.codecov.io/gh/zeromicro/go-zero/pull/3989?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeromicro).
> Report is 19 commits behind head on master.

<details><summary>Additional details and impacted files</summary>



| [Files](https://app.codecov.io/gh/zeromicro/go-zero/pull/3989?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeromicro) | Coverage Δ | |
|---|---|---|
| [core/bloom/bloom.go](https://app.codecov.io/gh/zeromicro/go-zero/pull/3989?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeromicro#diff-Y29yZS9ibG9vbS9ibG9vbS5nbw==) | `96.72% <100.00%> (+0.88%)` | :arrow_up: |
| [core/codec/dh.go](https://app.codecov.io/gh/zeromicro/go-zero/pull/3989?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeromicro#diff-Y29yZS9jb2RlYy9kaC5nbw==) | `82.85% <ø> (+3.31%)` | :arrow_up: |
| [core/collection/cache.go](https://app.codecov.io/gh/zeromicro/go-zero/pull/3989?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeromicro#diff-Y29yZS9jb2xsZWN0aW9uL2NhY2hlLmdv) | `87.05% <ø> (-0.01%)` | :arrow_down: |
| [core/conf/config.go](https://app.codecov.io/gh/zeromicro/go-zero/pull/3989?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeromicro#diff-Y29yZS9jb25mL2NvbmZpZy5nbw==) | `98.90% <100.00%> (+0.25%)` | :arrow_up: |
| [core/filex/progressscanner.go](https://app.codecov.io/gh/zeromicro/go-zero/pull/3989?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeromicro#diff-Y29yZS9maWxleC9wcm9ncmVzc3NjYW5uZXIuZ28=) | `100.00% <ø> (ø)` | |
| [core/fx/stream.go](https://app.codecov.io/gh/zeromicro/go-zero/pull/3989?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeromicro#diff-Y29yZS9meC9zdHJlYW0uZ28=) | `100.00% <ø> (ø)` | |
| [core/iox/pipe.go](https://app.codecov.io/gh/zeromicro/go-zero/pull/3989?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeromicro#diff-Y29yZS9pb3gvcGlwZS5nbw==) | `84.61% <ø> (+4.61%)` | :arrow_up: |
| [core/iox/textfile.go](https://app.codecov.io/gh/zeromicro/go-zero/pull/3989?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeromicro#diff-Y29yZS9pb3gvdGV4dGZpbGUuZ28=) | `90.00% <ø> (-2.00%)` | :arrow_down: |
| [core/iox/textlinescanner.go](https://app.codecov.io/gh/zeromicro/go-zero/pull/3989?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeromicro#diff-Y29yZS9pb3gvdGV4dGxpbmVzY2FubmVyLmdv) | `100.00% <ø> (ø)` | |
| [core/limit/tokenlimit.go](https://app.codecov.io/gh/zeromicro/go-zero/pull/3989?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeromicro#diff-Y29yZS9saW1pdC90b2tlbmxpbWl0Lmdv) | `94.20% <100.00%> (+0.30%)` | :arrow_up: |
| ... and [14 more](https://app.codecov.io/gh/zeromicro/go-zero/pull/3989?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeromicro) | |

... and [230 files with indirect coverage changes](https://app.codecov.io/gh/zeromicro/go-zero/pull/3989/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=zeromicro)

</details>

Patch:
diff --git a/core/bloom/bloom.go b/core/bloom/bloom.go
index 897f4bc8..3a72cf84 100644
--- a/core/bloom/bloom.go
+++ b/core/bloom/bloom.go
@@ -130,7 +130,7 @@ func (r *redisBitSet) check(ctx context.Context, offsets []uint) (bool, error) {
 	}
 
 	resp, err := r.store.ScriptRunCtx(ctx, testScript, []string{r.key}, args)
-	if err == redis.Nil {
+	if errors.Is(err, redis.Nil) {
 		return false, nil
 	} else if err != nil {
 		return false, err
@@ -162,7 +162,7 @@ func (r *redisBitSet) set(ctx context.Context, offsets []uint) error {
 	}
 
 	_, err = r.store.ScriptRunCtx(ctx, setScript, []string{r.key}, args)
-	if err == redis.Nil {
+	if errors.Is(err, redis.Nil) {
 		return nil
 	}
 
diff --git a/core/codec/dh.go b/core/codec/dh.go
index 49d839b4..63dd2d9c 100644
--- a/core/codec/dh.go
+++ b/core/codec/dh.go
@@ -23,7 +23,7 @@ var (
 	zero = big.NewInt(0)
 )
 
-// DhKey defines the Diffie Hellman key.
+// DhKey defines the Diffie-Hellman key.
 type DhKey struct {
 	PriKey *big.Int
 	PubKey *big.Int
@@ -46,7 +46,7 @@ func ComputeKey(pubKey, priKey *big.Int) (*big.Int, error) {
 	return new(big.Int).Exp(pubKey, priKey, p), nil
 }
 
-// GenerateKey returns a Diffie Hellman key.
+// GenerateKey returns a Diffie-Hellman key.
 func GenerateKey() (*DhKey, error) {
 	var err error
 	var x *big.Int
diff --git a/core/collection/cache.go b/core/collection/cache.go
index ace21ece..56b31811 100644
--- a/core/collection/cache.go
+++ b/core/collection/cache.go
@@ -128,8 +128,8 @@ func (c *Cache) Take(key string, fetch func() (any, error)) (any, error) {
 
 	var fresh bool
 	val, err := c.barrier.Do(key, func() (any, error) {
-		// because O(1) on map search in memory, and fetch is an IO query
-		// so we do double check, cache might be taken by another call
+		// because O(1) on map search in memory, and fetch is an IO query,
+		// so we do double-check, cache might be taken by another call
 		if val, ok := c.doGet(key); ok {
 			return val, nil
 		}
diff --git a/core/conf/config.go b/core/conf/config.go
index 64796ef7..d3795c0a 100644
--- a/core/conf/config.go
+++ b/core/conf/config.go
@@ -133,7 +133,7 @@ func addOrMergeFields(info *fieldInfo, key string, child *fieldInfo, fullName st
 			return newConflictKeyError(fullName)
 		}
 
-		if err := mergeFields(prev, key, child.children, fullName); err != nil {
+		if err := mergeFields(prev, child.children, fullName); err != nil {
 			return err
 		}
 	} else {
@@ -281,7 +281,7 @@ func getTagName(field reflect.StructField) string {
 	return field.Name
 }
 
-func mergeFields(prev *fieldInfo, key string, children map[string]*fieldInfo, fullName string) error {
+func mergeFields(prev *fieldInfo, children map[string]*fieldInfo, fullName string) error {
 	if len(prev.children) == 0 || len(children) == 0 {
 		return newConflictKeyError(fullName)
 	}
diff --git a/core/filex/progressscanner.go b/core/filex/progressscanner.go
index 11f3c1a5..e4f187f6 100644
--- a/core/filex/progressscanner.go
+++ b/core/filex/progressscanner.go
@@ -5,7 +5,7 @@ import "gopkg.in/cheggaaa/pb.v1"
 type (
 	// A Scanner is used to read lines.
 	Scanner interface {
-		// Scan checks if has remaining to read.
+		// Scan checks if it has remaining to read.
 		Scan() bool
 		// Text returns next line.
 		Text() string
diff --git a/core/fx/stream.go b/core/fx/stream.go
index cebb11e3..e0c3cd28 100644
--- a/core/fx/stream.go
+++ b/core/fx/stream.go
@@ -352,7 +352,7 @@ func (s Stream) Parallel(fn ParallelFunc, opts ...Option) {
 	}, opts...).Done()
 }
 
-// Reduce is an utility method to let the caller deal with the underlying channel.
+// Reduce is a utility method to let the caller deal with the underlying channel.
 func (s Stream) Reduce(fn ReduceFunc) (any, error) {
 	return fn(s.source)
 }
diff --git a/core/iox/pipe.go b/core/iox/pipe.go
index be36479c..044de380 100644
--- a/core/iox/pipe.go
+++ b/core/iox/pipe.go
@@ -2,7 +2,7 @@ package iox
 
 import "os"
 
-// RedirectInOut redirects stdin to r, stdout to w, and callers need to call restore afterwards.
+// RedirectInOut redirects stdin to r, stdout to w, and callers need to call restore afterward.
 func RedirectInOut() (restore func(), err error) {
 	var r, w *os.File
 	r, w, err = os.Pipe()
diff --git a/core/iox/textfile.go b/core/iox/textfile.go
index 89083cea..96309716 100644
--- a/core/iox/textfile.go
+++ b/core/iox/textfile.go
@@ -9,7 +9,7 @@ import (
 
 const bufSize = 32 * 1024
 
-// CountLines returns the number of lines in file.
+// CountLines returns the number of lines in the file.
 func CountLines(file string) (int, error) {
 	f, err := os.Open(file)
 	if err != nil {
diff --git a/core/iox/textlinescanner.go b/core/iox/textlinescanner.go
index ec28e27a..afa81652 100644
--- a/core/iox/textlinescanner.go
+++ b/core/iox/textlinescanner.go
@@ -6,7 +6,7 @@ import (
 	"strings"
 )
 
-// A TextLineScanner is a scanner that can scan lines from given reader.
+// A TextLineScanner is a scanner that can scan lines from the given reader.
 type TextLineScanner struct {
 	reader  *bufio.Reader
 	hasNext bool
@@ -14,7 +14,7 @@ type TextLineScanner struct {
 	err     error
 }
 
-// NewTextLineScanner returns a TextLineScanner with given reader.
+// NewTextLineScanner returns a TextLineScanner with the given reader.
 func NewTextLineScanner(reader io.Reader) *TextLineScanner {
 	return &TextLineScanner{
 		reader:  bufio.NewReader(reader),
diff --git a/core/limit/tokenlimit.go b/core/limit/tokenlimit.go
index fe576dd9..e33b4b95 100644
--- a/core/limit/tokenlimit.go
+++ b/core/limit/tokenlimit.go
@@ -125,7 +125,7 @@ func (lim *TokenLimiter) reserveN(ctx context.Context, now time.Time, n int) boo
 		})
 	// redis allowed == false
 	// Lua boolean false -> r Nil bulk reply
-	if err == redis.Nil {
+	if errors.Is(err, redis.Nil) {
 		return false
 	}
 	if errors.Is(err, context.DeadlineExceeded) || errors.Is(err, context.Canceled) {
diff --git a/core/load/adaptiveshedder.go b/core/load/adaptiveshedder.go
index a7b6f49d..2afc43a2 100644
--- a/core/load/adaptiveshedder.go
+++ b/core/load/adaptiveshedder.go
@@ -138,10 +138,10 @@ func (as *adaptiveShedder) Allow() (Promise, error) {
 func (as *adaptiveShedder) addFlying(delta int64) {
 	flying := atomic.AddInt64(&as.flying, delta)
 	// update avgFlying when the request is finished.
-	// this strategy makes avgFlying have a little bit lag against flying, and smoother.
+	// this strategy makes avgFlying have a little bit of lag against flying, and smoother.
 	// when the flying requests increase rapidly, avgFlying increase slower, accept more requests.
 	// when the flying requests drop rapidly, avgFlying drop slower, accept fewer requests.
-	// it makes the service to serve as more requests as possible.
+	// it makes the service to serve as many requests as possible.
 	if delta < 0 {
 		as.avgFlyingLock.Lock()
 		as.avgFlying = as.avgFlying*flyingBeta + float64(flying)*(1-flyingBeta)
@@ -200,7 +200,7 @@ func (as *adaptiveShedder) minRt() float64 {
 func (as *adaptiveShedder) overloadFactor() float64 {
 	// as.cpuThreshold must be less than cpuMax
 	factor := (cpuMax - float64(stat.CpuUsage())) / (cpuMax - float64(as.cpuThreshold))
-	// at least accept 10% of acceptable requests even cpu is highly overloaded.
+	// at least accept 10% of acceptable requests, even cpu is highly overloaded.
 	return mathx.Between(factor, overloadFactorLowerBound, 1)
 }
 
@@ -250,14 +250,14 @@ func (as *adaptiveShedder) systemOverloaded() bool {
 	return true
 }
 
-// WithBuckets customizes the Shedder with given number of buckets.
+// WithBuckets customizes the Shedder with the given number of buckets.
 func WithBuckets(buckets int) ShedderOption {
 	return func(opts *shedderOptions) {
 		opts.buckets = buckets
 	}
 }
 
-// WithCpuThreshold customizes the Shedder with given cpu threshold.
+// WithCpuThreshold customizes the Shedder with the given cpu threshold.
 func WithCpuThreshold(threshold int64) ShedderOption {
 	return func(opts *shedderOptions) {
 		opts.cpuThreshold = threshold
diff --git a/core/load/sheddergroup.go b/core/load/sheddergroup.go
index c3d62402..8cc742f5 100644
--- a/core/load/sheddergroup.go
+++ b/core/load/sheddergroup.go
@@ -6,7 +6,7 @@ import (
 	"github.com/zeromicro/go-zero/core/syncx"
 )
 
-// A ShedderGroup is a manager to manage key based shedders.
+// A ShedderGroup is a manager to manage key-based shedders.
 type ShedderGroup struct {
 	options []ShedderOption
 	manager *syncx.ResourceManager
diff --git a/core/logc/logs.go b/core/logc/logs.go
index 71233545..b8343fa2 100644
--- a/core/logc/logs.go
+++ b/core/logc/logs.go
@@ -42,7 +42,7 @@ func Debugv(ctx context.Context, v interface{}) {
 	getLogger(ctx).Debugv(v)
 }
 
-// Debugw writes msg along with fields into access log.
+// Debugw writes msg along with fields into the access log.
 func Debugw(ctx context.Context, msg string, fields ...LogField) {
 	getLogger(ctx).Debugw(msg, fields...)
 }
@@ -63,7 +63,7 @@ func Errorv(ctx context.Context, v any) {
 	getLogger(ctx).Errorv(v)
 }
 
-// Errorw writes msg along with fields into error log.
+// Errorw writes msg along with fields into the error log.
 func Errorw(ctx context.Context, msg string, fields ...LogField) {
 	getLogger(ctx).Errorw(msg, fields...)
 }
@@ -88,7 +88,7 @@ func Infov(ctx context.Context, v any) {
 	getLogger(ctx).Infov(v)
 }
 
-// Infow writes msg along with fields into access log.
+// Infow writes msg along with fields into the access log.
 func Infow(ctx context.Context, msg string, fields ...LogField) {
 	getLogger(ctx).Infow(msg, fields...)
 }
@@ -108,10 +108,11 @@ func SetLevel(level uint32) {
 	logx.SetLevel(level)
 }
 
-// SetUp sets up the logx. If already set up, just return nil.
-// we allow SetUp to be called multiple times, because for example
+// SetUp sets up the logx.
+// If already set up, return nil.
+// We allow SetUp to be called multiple times, because, for example,
 // we need to allow different service frameworks to initialize logx respectively.
-// the same logic for SetUp
+// The same logic for SetUp
 func SetUp(c LogConf) error {
 	return logx.SetUp(c)
 }
diff --git a/core/logx/lesslogger.go b/core/logx/lesslogger.go
index 35ca2051..04113929 100644
--- a/core/logx/lesslogger.go
+++ b/core/logx/lesslogger.go
@@ -1,6 +1,6 @@
 package logx
 
-// A LessLogger is a logger that control to log once during the given duration.
+// A LessLogger is a logger that controls to log once during the given duration.
 type LessLogger struct {
 	*limitedExecutor
 }
diff --git a/core/logx/logs.go b/core/logx/logs.go
index 0c049324..780093eb 100644
--- a/core/logx/logs.go
+++ b/core/logx/logs.go
@@ -86,7 +86,7 @@ func Debugv(v any) {
 	}
 }
 
-// Debugw writes msg along with fields into access log.
+// Debugw writes msg along with fields into the access log.
 func Debugw(msg string, fields ...LogField) {
 	if shallLog(DebugLevel) {
 		writeDebug(msg, fields...)
@@ -142,7 +142,7 @@ func Errorv(v any) {
 	}
 }
 
-// Errorw writes msg along with fields into error log.
+// Errorw writes msg along with fields into the error log.
 func Errorw(msg string, fields ...LogField) {
 	if shallLog(ErrorLevel) {
 		writeError(msg, fields...)
@@ -208,7 +208,7 @@ func Infov(v any) {
 	}
 }
 
-// Infow writes msg along with fields into access log.
+// Infow writes msg along with fields into the access log.
 func Infow(msg string, fields ...LogField) {
 	if shallLog(InfoLevel) {
 		writeInfo(msg, fields...)
@@ -254,11 +254,12 @@ func SetWriter(w Writer) {
 	}
 }
 
-// SetUp sets up the logx. If already set up, just return nil.
-// we allow SetUp to be called multiple times, because for example
+// SetUp sets up the logx.
+// If already set up, return nil.
+// We allow SetUp to be called multiple times, because, for example,
 // we need to allow different service frameworks to initialize logx respectively.
 func SetUp(c LogConf) (err error) {
-	// Just ignore the subsequent SetUp calls.
+	// Ignore the later SetUp calls.
 	// Because multiple services in one process might call SetUp respectively.
 	// Need to wait for the first caller to complete the execution.
 	setupOnce.Do(func() {
@@ -480,7 +481,7 @@ func writeDebug(val any, fields ...LogField) {
 	getWriter().Debug(val, addCaller(fields...)...)
 }
 
-// writeError writes v into error log.
+// writeError writes v into the error log.
 // Not checking shallLog here is for performance consideration.
 // If we check shallLog here, the fmt.Sprint might be called even if the log level is not enabled.
 // The caller should check shallLog before calling this function.
@@ -520,7 +521,7 @@ func writeStack(msg string) {
 	getWriter().Stack(fmt.Sprintf("%s\n%s", msg, string(debug.Stack())))
 }
 
-// writeStat writes v into stat log.
+// writeStat writes v into the stat log.
 // Not checking shallLog here is for performance consideration.
 // If we check shallLog here, the fmt.Sprint might be called even if the log level is not enabled.
 // The caller should check shallLog before calling this function.
diff --git a/core/logx/rotatelogger.go b/core/logx/rotatelogger.go
index 4b7f31e7..61f9a9d0 100644
--- a/core/logx/rotatelogger.go
+++ b/core/logx/rotatelogger.go
@@ -319,7 +319,7 @@ func (l *RotateLogger) maybeCompressFile(file string) {
 	}()
 
 	if _, err := os.Stat(file); err != nil {
-		// file not exists or other error, ignore compression
+		// file doesn't exist or another error, ignore compression
 		return
 	}
 
diff --git a/core/mapping/marshaler.go b/core/mapping/marshaler.go
index c54ae747..fbe31a92 100644
--- a/core/mapping/marshaler.go
+++ b/core/mapping/marshaler.go
@@ -12,7 +12,7 @@ const (
 )
 
 // Marshal marshals the given val and returns the map that contains the fields.
-// optional=another is not implemented, and it's hard to implement and not common used.
+// optional=another is not implemented, and it's hard to implement and not commonly used.
 func Marshal(val any) (map[string]map[string]any, error) {
 	ret := make(map[string]map[string]any)
 	tp := reflect.TypeOf(val)
diff --git a/core/mapping/unmarshaler.go b/core/mapping/unmarshaler.go
index fbaeb69a..12cbe46b 100644
--- a/core/mapping/unmarshaler.go
+++ b/core/mapping/unmarshaler.go
@@ -39,7 +39,7 @@ var (
 )
 
 type (
-	// Unmarshaler is used to unmarshal with given tag key.
+	// Unmarshaler is used to unmarshal with the given tag key.
 	Unmarshaler struct {
 		key  string
 		opts unmarshalOptions
@@ -69,7 +69,7 @@ func NewUnmarshaler(key string, opts ...UnmarshalOption) *Unmarshaler {
 	return &unmarshaler
 }
 
-// UnmarshalKey unmarshals m into v with tag key.
+// UnmarshalKey unmarshals m into v with the tag key.
 func UnmarshalKey(m map[string]any, v any) error {
 	return keyUnmarshaler.Unmarshal(m, v)
 }
@@ -629,7 +629,7 @@ func (u *Unmarshaler) processFieldPrimitiveWithJSONNumber(fieldType reflect.Type
 			return err
 		}
 
-		// if value is a pointer, we need to check overflow with the pointer's value.
+		// if the value is a pointer, we need to check overflow with the pointer's value.
 		derefedValue := value
 		for derefedValue.Type().Kind() == reflect.Ptr {
 			derefedValue = derefedValue.Elem()
diff --git a/core/mapping/utils.go b/core/mapping/utils.go
index d7c84af4..f84167e3 100644
--- a/core/mapping/utils.go
+++ b/core/mapping/utils.go
@@ -416,7 +416,7 @@ func parseOption(fieldOpts *fieldOptions, fieldName, option string) error {
 }
 
 // parseOptions parses the given options in tag.
-// for example: `json:"name,options=foo|bar"` or `json:"name,options=[foo,bar]"`
+// for example, `json:"name,options=foo|bar"` or `json:"name,options=[foo,bar]"`
 func parseOptions(val string) []string {
 	if len(val) == 0 {
 		return nil
diff --git a/core/mapping/valuer.go b/core/mapping/valuer.go
index 206b1b13..24f6f7f3 100644
--- a/core/mapping/valuer.go
+++ b/core/mapping/valuer.go
@@ -26,9 +26,9 @@ type (
 		parent valuerWithParent
 	}
 
-	// mapValuer is a type for map to meet the Valuer interface.
+	// mapValuer is a type for the map to meet the Valuer interface.
 	mapValuer map[string]any
-	// simpleValuer is a type to get value from current node.
+	// simpleValuer is a type to get value from the current node.
 	simpleValuer node
 	// recursiveValuer is a type to get the value recursively from current and parent nodes.
 	recursiveValuer node
diff --git a/core/queue/queue.go b/core/queue/queue.go
index 81aaaae4..5a9fd5c9 100644
--- a/core/queue/queue.go
+++ b/core/queue/queue.go
@@ -76,7 +76,7 @@ func (q *Queue) AddListener(listener Listener) {
 	q.listeners = append(q.listeners, listener)
 }
 
-// Broadcast broadcasts message to all event channels.
+// Broadcast broadcasts the message to all event channels.
 func (q *Queue) Broadcast(message any) {
 	go func() {
 		q.eventLock.Lock()
@@ -202,7 +202,7 @@ func (q *Queue) produce() {
 }
 
 func (q *Queue) produceOne(producer Producer) (string, bool) {
-	// avoid panic quit the producer, just log it and continue
+	// avoid panic quit the producer, log it and continue
 	defer rescue.Recover()
 
 	return producer.Produce()
diff --git a/core/stat/task.go b/core/stat/task.go
index 637e0b76..203248f2 100644
--- a/core/stat/task.go
+++ b/core/stat/task.go
@@ -2,7 +2,7 @@ package stat
 
 import "time"
 
-// A Task is a task that is reported to Metrics.
+// A Task is a task reported to Metrics.
 type Task struct {
 	Drop        bool
 	Duration    time.Duration
diff --git a/core/stores/cache/cacheopt.go b/core/stores/cache/cacheopt.go
index cc8d459d..836c12af 100644
--- a/core/stores/cache/cacheopt.go
+++ b/core/stores/cache/cacheopt.go
@@ -8,7 +8,7 @@ const (
 )
 
 type (
-	// An Options is used to store the cache options.
+	// Options is used to store the cache options.
 	Options struct {
 		Expiry         time.Duration
 		NotFoundExpiry time.Duration
diff --git a/core/stores/redis/conf.go b/core/stores/redis/conf.go
index c5421087..5328757f 100644
--- a/core/stores/redis/conf.go
+++ b/core/stores/redis/conf.go
@@ -47,7 +47,7 @@ func (rc RedisConf) NewRedis() *Redis {
 		opts = append(opts, WithTLS())
 	}
 
-	return New(rc.Host, opts...)
+	return newRedis(rc.Host, opts...)
 }
 
 // Validate validates the RedisConf.
diff --git a/core/stores/redis/redislock.go b/core/stores/redis/redislock.go
index f335d6c8..ab26cc98 100644
--- a/core/stores/redis/redislock.go
+++ b/core/stores/redis/redislock.go
@@ -2,6 +2,7 @@ package redis
 
 import (
 	"context"
+	"errors"
 	"math/rand"
 	"strconv"
 	"sync/atomic"
@@ -64,7 +65,7 @@ func (rl *RedisLock) AcquireCtx(ctx context.Context) (bool, error) {
 	resp, err := rl.store.ScriptRunCtx(ctx, lockScript, []string{rl.key}, []string{
 		rl.id, strconv.Itoa(int(seconds)*millisPerSecond + tolerance),
 	})
-	if err == red.Nil {
+	if errors.Is(err, red.Nil) {
 		return false, nil
 	} else if err != nil {
 		logx.Errorf("Error on acquiring lock for %s, %s", rl.key, err.Error())
diff --git a/core/trace/vars.go b/core/trace/vars.go
index d8cee290..33d2e6c9 100644
--- a/core/trace/vars.go
+++ b/core/trace/vars.go
@@ -4,5 +4,5 @@ import "net/http"
 
 // TraceIdKey is the trace id header.
 // https://www.w3.org/TR/trace-context/#trace-id
-// May change it to trace-id afterwards.
+// May change it to trace-id afterward.
 var TraceIdKey = http.CanonicalHeaderKey("x-trace-id")


Test patch:
diff --git a/core/logx/logs_test.go b/core/logx/logs_test.go
index 818f459e..3780bc2f 100644
--- a/core/logx/logs_test.go
+++ b/core/logx/logs_test.go
@@ -570,7 +570,7 @@ func TestErrorfWithWrappedError(t *testing.T) {
 	old := writer.Swap(w)
 	defer writer.Store(old)
 
-	Errorf("hello %w", errors.New(message))
+	Errorf("hello %s", errors.New(message))
 	assert.True(t, strings.Contains(w.String(), "hello there"))
 }
 
diff --git a/core/mapping/unmarshaler_test.go b/core/mapping/unmarshaler_test.go
index 08a80495..ac5a30c0 100644
--- a/core/mapping/unmarshaler_test.go
+++ b/core/mapping/unmarshaler_test.go
@@ -5866,7 +5866,7 @@ type mockValuerWithParent struct {
 	ok     bool
 }
 
-func (m mockValuerWithParent) Value(key string) (any, bool) {
+func (m mockValuerWithParent) Value(_ string) (any, bool) {
 	return m.value, m.ok
 }
 
diff --git a/core/proc/goroutines_test.go b/core/proc/goroutines_test.go
index 827d0233..4d515462 100644
--- a/core/proc/goroutines_test.go
+++ b/core/proc/goroutines_test.go
@@ -36,6 +36,6 @@ type fakeCreator struct {
 	err  error
 }
 
-func (fc fakeCreator) Create(name string) (file *os.File, err error) {
+func (fc fakeCreator) Create(_ string) (file *os.File, err error) {
 	return fc.file, fc.err
 }
diff --git a/core/queue/util_test.go b/core/queue/util_test.go
index f578c364..eca6b797 100644
--- a/core/queue/util_test.go
+++ b/core/queue/util_test.go
@@ -67,7 +67,7 @@ func (p *mockedPusher) Name() string {
 	return p.name
 }
 
-func (p *mockedPusher) Push(s string) error {
+func (p *mockedPusher) Push(_ string) error {
 	if proba.TrueOnProba(failProba) {
 		return errors.New("dummy")
 	}
diff --git a/core/stat/metrics_test.go b/core/stat/metrics_test.go
index 30f8d316..ea686560 100644
--- a/core/stat/metrics_test.go
+++ b/core/stat/metrics_test.go
@@ -71,6 +71,6 @@ func (m *mockedWriter) Write(report *StatReport) error {
 
 type badWriter struct{}
 
-func (b *badWriter) Write(report *StatReport) error {
+func (b *badWriter) Write(_ *StatReport) error {
 	return errors.New("bad")
 }
diff --git a/core/trace/message_test.go b/core/trace/message_test.go
index 039a5e76..290158f8 100644
--- a/core/trace/message_test.go
+++ b/core/trace/message_test.go
@@ -34,7 +34,7 @@ type mockSpan struct {
 	options []trace.EventOption
 }
 
-func (m *mockSpan) End(options ...trace.SpanEndOption) {
+func (m *mockSpan) End(_ ...trace.SpanEndOption) {
 }
 
 func (m *mockSpan) AddEvent(name string, options ...trace.EventOption) {
@@ -46,20 +46,20 @@ func (m *mockSpan) IsRecording() bool {
 	return false
 }
 
-func (m *mockSpan) RecordError(err error, options ...trace.EventOption) {
+func (m *mockSpan) RecordError(_ error, _ ...trace.EventOption) {
 }
 
 func (m *mockSpan) SpanContext() trace.SpanContext {
 	panic("implement me")
 }
 
-func (m *mockSpan) SetStatus(code codes.Code, description string) {
+func (m *mockSpan) SetStatus(_ codes.Code, _ string) {
 }
 
-func (m *mockSpan) SetName(name string) {
+func (m *mockSpan) SetName(_ string) {
 }
 
-func (m *mockSpan) SetAttributes(kv ...attribute.KeyValue) {
+func (m *mockSpan) SetAttributes(_ ...attribute.KeyValue) {
 }
 
 func (m *mockSpan) TracerProvider() trace.TracerProvider {