diff --git a/nstr/ac/ahocorasick.go b/nstr/ac/ahocorasick.go index 2662b88..73b86d9 100644 --- a/nstr/ac/ahocorasick.go +++ b/nstr/ac/ahocorasick.go @@ -157,7 +157,7 @@ func (ac AhoCorasick) IterOverlappingByte(haystack []byte) Iter { } var pool = sync.Pool{ - New: func() interface{} { + New: func() any { return strings.Builder{} }, } diff --git a/nstr/ac/prefilter.go b/nstr/ac/prefilter.go index 55b7876..573097e 100644 --- a/nstr/ac/prefilter.go +++ b/nstr/ac/prefilter.go @@ -10,7 +10,7 @@ type startBytesThree struct { byte3 byte } -func (s *startBytesThree) NextCandidate(_ *prefilterState, haystack []byte, at int) (interface{}, candidateType) { +func (s *startBytesThree) NextCandidate(_ *prefilterState, haystack []byte, at int) (any, candidateType) { for i, b := range haystack[at:] { if s.byte1 == b || s.byte2 == b || s.byte3 == b { return at + i, possibleStartOfMatchCandidate @@ -44,7 +44,7 @@ type startBytesTwo struct { byte2 byte } -func (s *startBytesTwo) NextCandidate(_ *prefilterState, haystack []byte, at int) (interface{}, candidateType) { +func (s *startBytesTwo) NextCandidate(_ *prefilterState, haystack []byte, at int) (any, candidateType) { for i, b := range haystack[at:] { if s.byte1 == b || s.byte2 == b { return at + i, possibleStartOfMatchCandidate @@ -77,7 +77,7 @@ type startBytesOne struct { byte1 byte } -func (s *startBytesOne) NextCandidate(_ *prefilterState, haystack []byte, at int) (interface{}, candidateType) { +func (s *startBytesOne) NextCandidate(_ *prefilterState, haystack []byte, at int) (any, candidateType) { for i, b := range haystack[at:] { if s.byte1 == b { return at + i, possibleStartOfMatchCandidate @@ -192,7 +192,7 @@ type rareBytesOne struct { offset rareByteOffset } -func (r *rareBytesOne) NextCandidate(state *prefilterState, haystack []byte, at int) (interface{}, candidateType) { +func (r *rareBytesOne) NextCandidate(state *prefilterState, haystack []byte, at int) (any, candidateType) { for i, b := range haystack[at:] { if r.byte1 == b { pos := at + i @@ -237,7 +237,7 @@ type rareBytesTwo struct { byte2 byte } -func (r *rareBytesTwo) NextCandidate(state *prefilterState, haystack []byte, at int) (interface{}, candidateType) { +func (r *rareBytesTwo) NextCandidate(state *prefilterState, haystack []byte, at int) (any, candidateType) { for i, b := range haystack[at:] { if r.byte1 == b || r.byte2 == b { pos := at + i @@ -283,7 +283,7 @@ type rareBytesThree struct { byte3 byte } -func (r *rareBytesThree) NextCandidate(state *prefilterState, haystack []byte, at int) (interface{}, candidateType) { +func (r *rareBytesThree) NextCandidate(state *prefilterState, haystack []byte, at int) (any, candidateType) { for i, b := range haystack[at:] { if r.byte1 == b || r.byte2 == b || r.byte3 == b { pos := at + i @@ -577,14 +577,14 @@ const ( ) type prefilter interface { - NextCandidate(state *prefilterState, haystack []byte, at int) (interface{}, candidateType) + NextCandidate(state *prefilterState, haystack []byte, at int) (any, candidateType) HeapBytes() int ReportsFalsePositives() bool LooksForNonStartOfMatch() bool clone() prefilter } -func nextPrefilter(state *prefilterState, prefilter prefilter, haystack []byte, at int) (interface{}, candidateType) { +func nextPrefilter(state *prefilterState, prefilter prefilter, haystack []byte, at int) (any, candidateType) { candidate, typ := prefilter.NextCandidate(state, haystack, at) switch typ { diff --git a/nsys/cmdn/serializer_plain.go b/nsys/cmdn/serializer_plain.go index a606e65..58d91e1 100644 --- a/nsys/cmdn/serializer_plain.go +++ b/nsys/cmdn/serializer_plain.go @@ -18,7 +18,7 @@ func NewPlainSerializer() ndef.Serializer { } } -func (s *PlainSerializer) Marshal(v interface{}) ([]byte, error) { +func (s *PlainSerializer) Marshal(v any) ([]byte, error) { ret, ok := v.(*PlainCommand) if !ok { return nil, errors.New(fmt.Sprintf("参数类型必须为 %T", PlainCommand{})) @@ -36,7 +36,7 @@ func (s *PlainSerializer) Marshal(v interface{}) ([]byte, error) { return []byte(sb.String()), nil } -func (s *PlainSerializer) Unmarshal(data []byte, v interface{}) error { +func (s *PlainSerializer) Unmarshal(data []byte, v any) error { t, ok := v.(*PlainResp) if !ok { return errors.New(fmt.Sprintf("参数类型必须为 %T", PlainResp{}))