diff --git a/pkg/compiler/compiler.go b/pkg/compiler/compiler.go index 191bfb848..7e47f844d 100644 --- a/pkg/compiler/compiler.go +++ b/pkg/compiler/compiler.go @@ -11,7 +11,7 @@ import ( "io" "os" "path/filepath" - "sort" + "slices" "strings" "github.com/nspcc-dev/neo-go/pkg/smartcontract" @@ -362,7 +362,7 @@ func CompileAndSave(src string, o *Options) ([]byte, error) { for k := range di.EmittedEvents { keys = append(keys, k) } - sort.Strings(keys) + slices.Sort(keys) for _, eventName := range keys { var ( eventUsages = di.EmittedEvents[eventName] diff --git a/pkg/compiler/debug.go b/pkg/compiler/debug.go index 70fe6751d..ea75e3d6c 100644 --- a/pkg/compiler/debug.go +++ b/pkg/compiler/debug.go @@ -6,7 +6,7 @@ import ( "fmt" "go/ast" "go/types" - "sort" + "slices" "strconv" "strings" "unicode" @@ -210,7 +210,7 @@ func (c *codegen) emitDebugInfo(contract []byte) *DebugInfo { } fnames = append(fnames, name) } - sort.Strings(fnames) + slices.Sort(fnames) d.NamedTypes = make(map[string]binding.ExtendedType) for _, name := range fnames { m := c.methodInfoFromScope(name, c.funcs[name], d.NamedTypes) diff --git a/pkg/config/application_config.go b/pkg/config/application_config.go index 17a74389a..9ac369238 100644 --- a/pkg/config/application_config.go +++ b/pkg/config/application_config.go @@ -3,7 +3,6 @@ package config import ( "fmt" "slices" - "sort" "strconv" "strings" @@ -41,8 +40,8 @@ func (a *ApplicationConfiguration) EqualsButServices(o *ApplicationConfiguration } aCp := slices.Clone(a.P2P.Addresses) oCp := slices.Clone(o.P2P.Addresses) - sort.Strings(aCp) - sort.Strings(oCp) + slices.Sort(aCp) + slices.Sort(oCp) if !slices.Equal(aCp, oCp) { return false } diff --git a/pkg/network/discovery_test.go b/pkg/network/discovery_test.go index c27dc5c5d..ad29aed81 100644 --- a/pkg/network/discovery_test.go +++ b/pkg/network/discovery_test.go @@ -3,7 +3,7 @@ package network import ( "errors" "net" - "sort" + "slices" "sync/atomic" "testing" "time" @@ -91,7 +91,7 @@ func TestDefaultDiscoverer(t *testing.T) { tryMaxWait = 1 // Don't waste time. var set1 = []string{"1.1.1.1:10333", "2.2.2.2:10333"} - sort.Strings(set1) + slices.Sort(set1) // Added addresses should end up in the pool and in the unconnected set. // Done twice to check re-adding unconnected addresses, which should be @@ -100,7 +100,7 @@ func TestDefaultDiscoverer(t *testing.T) { d.BackFill(set1...) assert.Equal(t, len(set1), d.PoolCount()) set1D := d.UnconnectedPeers() - sort.Strings(set1D) + slices.Sort(set1D) assert.Equal(t, 0, len(d.GoodPeers())) assert.Equal(t, 0, len(d.BadPeers())) require.Equal(t, set1, set1D) @@ -120,7 +120,7 @@ func TestDefaultDiscoverer(t *testing.T) { } } require.Eventually(t, func() bool { return len(d.UnconnectedPeers()) == 0 }, 2*time.Second, 50*time.Millisecond) - sort.Strings(dialled) + slices.Sort(dialled) assert.Equal(t, 0, d.PoolCount()) assert.Equal(t, 0, len(d.BadPeers())) assert.Equal(t, 0, len(d.GoodPeers())) @@ -150,7 +150,7 @@ func TestDefaultDiscoverer(t *testing.T) { }, addr.Capabilities) gAddrs[i] = addr.Address } - sort.Strings(gAddrs) + slices.Sort(gAddrs) assert.Equal(t, 0, d.PoolCount()) assert.Equal(t, 0, len(d.UnconnectedPeers())) assert.Equal(t, 0, len(d.BadPeers())) @@ -176,7 +176,7 @@ func TestDefaultDiscoverer(t *testing.T) { ts.retFalse.Store(1) assert.Equal(t, len(set1), d.PoolCount()) set1D := d.UnconnectedPeers() - sort.Strings(set1D) + slices.Sort(set1D) assert.Equal(t, 0, len(d.BadPeers())) require.Equal(t, set1, set1D) @@ -193,7 +193,7 @@ func TestDefaultDiscoverer(t *testing.T) { } } require.Eventually(t, func() bool { return d.PoolCount() == 0 }, 2*time.Second, 50*time.Millisecond) - sort.Strings(dialledBad) + slices.Sort(dialledBad) for i := 0; i < len(set1); i++ { for j := 0; j < connRetries; j++ { assert.Equal(t, set1[i], dialledBad[i*connRetries+j]) @@ -216,7 +216,7 @@ func TestSeedDiscovery(t *testing.T) { ts := &fakeTransp{} ts.dialCh = make(chan string) ts.retFalse.Store(1) // Fail all dial requests. - sort.Strings(seeds) + slices.Sort(seeds) d := NewDefaultDiscovery(seeds, time.Second/10, ts) tryMaxWait = 1 // Don't waste time. diff --git a/pkg/rpcclient/wsclient_test.go b/pkg/rpcclient/wsclient_test.go index 78805fc15..e1f0dd82e 100644 --- a/pkg/rpcclient/wsclient_test.go +++ b/pkg/rpcclient/wsclient_test.go @@ -6,7 +6,7 @@ import ( "fmt" "net/http" "net/http/httptest" - "sort" + "slices" "strconv" "strings" "sync" @@ -866,7 +866,7 @@ func TestWSConcurrentAccess(t *testing.T) { } ids.lock.RUnlock() - sort.Ints(idsList) + slices.Sort(idsList) require.Equal(t, 1, idsList[0]) require.Less(t, idsList[len(idsList)-1], batchCount*3+1) // batchCount*requestsPerBatch+1 diff --git a/pkg/smartcontract/binding/generate.go b/pkg/smartcontract/binding/generate.go index 24939f458..507078a9a 100644 --- a/pkg/smartcontract/binding/generate.go +++ b/pkg/smartcontract/binding/generate.go @@ -6,7 +6,7 @@ import ( "go/format" "go/token" "io" - "sort" + "slices" "strconv" "strings" "text/template" @@ -159,7 +159,7 @@ func Generate(cfg Config) error { if ctr.Hash != "" { ctr.Imports = append(ctr.Imports, "github.com/nspcc-dev/neo-go/pkg/interop/neogointernal") } - sort.Strings(ctr.Imports) + slices.Sort(ctr.Imports) return FExecute(srcTemplate, cfg.Output, ctr) } diff --git a/pkg/smartcontract/manifest/parameter.go b/pkg/smartcontract/manifest/parameter.go index 3e7424522..589c39f6d 100644 --- a/pkg/smartcontract/manifest/parameter.go +++ b/pkg/smartcontract/manifest/parameter.go @@ -3,6 +3,7 @@ package manifest import ( "errors" "fmt" + "slices" "sort" "github.com/nspcc-dev/neo-go/pkg/smartcontract" @@ -94,7 +95,7 @@ func (p Parameters) AreValid() error { // stringsHaveDups checks the given set of strings for duplicates. It modifies the slice given! func stringsHaveDups(strings []string) bool { - sort.Strings(strings) + slices.Sort(strings) for i := range strings { if i == 0 { continue diff --git a/pkg/smartcontract/rpcbinding/binding.go b/pkg/smartcontract/rpcbinding/binding.go index 30520420d..e6abd9868 100644 --- a/pkg/smartcontract/rpcbinding/binding.go +++ b/pkg/smartcontract/rpcbinding/binding.go @@ -848,7 +848,7 @@ func scTemplateToRPC(cfg binding.Config, ctr ContractTmpl, imports map[string]st for imp := range imports { ctr.Imports = append(ctr.Imports, imp) } - sort.Strings(ctr.Imports) + slices.Sort(ctr.Imports) return ctr }