Skip to content

Commit

Permalink
Upd/go 1.22 (#2927)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov authored Sep 5, 2024
2 parents de5a12c + b44048e commit d214b0c
Show file tree
Hide file tree
Showing 71 changed files with 124 additions and 158 deletions.
2 changes: 1 addition & 1 deletion .docker/Dockerfile.adm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22 as builder
FROM golang:1.23 as builder
ARG BUILD=now
ARG VERSION=dev
ARG REPO=repository
Expand Down
2 changes: 1 addition & 1 deletion .docker/Dockerfile.cli
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22 as builder
FROM golang:1.23 as builder
ARG BUILD=now
ARG VERSION=dev
ARG REPO=repository
Expand Down
2 changes: 1 addition & 1 deletion .docker/Dockerfile.ir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22 as builder
FROM golang:1.23 as builder
ARG BUILD=now
ARG VERSION=dev
ARG REPO=repository
Expand Down
2 changes: 1 addition & 1 deletion .docker/Dockerfile.storage
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22 as builder
FROM golang:1.23 as builder
ARG BUILD=now
ARG VERSION=dev
ARG REPO=repository
Expand Down
2 changes: 1 addition & 1 deletion .docker/Dockerfile.storage-testnet
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22 as builder
FROM golang:1.23 as builder
ARG BUILD=now
ARG VERSION=dev
ARG REPO=repository
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ jobs:
strategy:
matrix:
os: [ubuntu-22.04, macos-14]
go: [ '1.21', '1.22', '1.23' ]
go: [ '1.22', '1.23' ]
exclude:
# Only the latest Go version MacOS.
- os: macos-14
go: '1.21'
- os: macos-14
go: '1.22'
# Exclude the latest Go version for Ubuntu as Coverage uses it.
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ linters:
- gofmt
- goimports
- gomodguard
- intrange
- misspell
- predeclared
- reassign
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Changelog for NeoFS Node
### Removed

### Updated
- Go to 1.21 version (#2517)
- Go to 1.22 version (#2517, #2738)

### Updating from v0.43.0

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The latest version of neofs-node works with neofs-contract

# Building

To make all binaries you need Go 1.20+ and `make`:
To make all binaries you need Go 1.22+ and `make`:
```
make all
```
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-adm/internal/modules/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func generateConfigExample(appDir string, credSize int) (string, error) {
}
tmpl.AlphabetDir = filepath.Join(appDir, "alphabet-wallets")

for i := 0; i < credSize; i++ {
for i := range credSize {
tmpl.Glagolitics = append(tmpl.Glagolitics, glagolitsa.LetterByIndex(i))
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-adm/internal/modules/morph/dump_hashes.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func dumpContractHashes(cmd *cobra.Command, _ []string) error {
}

var contracts = make([]string, 0, irSize+len(contractList))
for i := 0; i < irSize; i++ {
for i := range irSize {
contracts = append(contracts, getAlphabetNNSDomain(i))
}
contracts = append(contracts, contractList...)
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-adm/internal/modules/morph/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func createWallets(fileNameTemplate, label, password string, number uint32) ([]u
base := strings.TrimSuffix(fileNameTemplate, ext)
walletNumberFormat := fmt.Sprintf("%%0%dd", digitsNum(number))

for i := 0; i < int(number); i++ {
for i := range int(number) {
filename := fileNameTemplate
if number != 1 {
filename = base + "_" + fmt.Sprintf(walletNumberFormat, i) + ext
Expand Down
4 changes: 2 additions & 2 deletions cmd/neofs-adm/internal/modules/morph/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func openAlphabetWallets(v *viper.Viper, walletDir string) ([]*wallet.Wallet, er

var size int
loop:
for i := 0; i < len(walletFiles); i++ {
for i := range walletFiles {
name := glagolitsa.LetterByIndex(i) + ".json"
for j := range walletFiles {
if walletFiles[j].Name() == name {
Expand All @@ -213,7 +213,7 @@ loop:
}

wallets := make([]*wallet.Wallet, size)
for i := 0; i < size; i++ {
for i := range size {
letter := glagolitsa.LetterByIndex(i)
p := filepath.Join(walletDir, letter+".json")
w, err := wallet.NewWalletFromFile(p)
Expand Down
4 changes: 2 additions & 2 deletions cmd/neofs-adm/internal/modules/morph/initialize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func generateTestData(t *testing.T, dir string, size int) {
require.NoError(t, generateAlphabetCreds(generateAlphabetCmd, nil))

var pubs []string
for i := 0; i < size; i++ {
for i := range size {
p := filepath.Join(dir, glagolitsa.LetterByIndex(i)+".json")
w, err := wallet.NewWalletFromFile(p)
require.NoError(t, err, "wallet doesn't exist")
Expand Down Expand Up @@ -110,7 +110,7 @@ func generateTestData(t *testing.T, dir string, size int) {
}

func setTestCredentials(v *viper.Viper, size int) {
for i := 0; i < size; i++ {
for i := range size {
v.Set("credentials."+glagolitsa.LetterByIndex(i), strconv.FormatUint(uint64(i), 10))
}
}
2 changes: 1 addition & 1 deletion cmd/neofs-cli/modules/util/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func PrettyPrintTableBACL(cmd *cobra.Command, bacl *acl.Basic) {
fmt.Fprintln(w, strings.Join(bits, "\t"))
// Footer
footer := []string{"X F"}
for i := 0; i < 7; i++ {
for range 7 {
footer = append(footer, "U S O B")
}
fmt.Fprintln(w, strings.Join(footer, "\t"))
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-node/config/node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func BootstrapAddresses(c *config.Config) (addr network.AddressGroup) {
func Attributes(c *config.Config) (attrs []string) {
const maxAttributes = 100

for i := 0; i < maxAttributes; i++ {
for i := range maxAttributes {
attr := config.StringSafe(c.Sub(subsection), attributePrefix+"_"+strconv.Itoa(i))
if attr == "" {
return
Expand Down
2 changes: 1 addition & 1 deletion cmd/neofs-node/reputation/ticker/fixed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestFixedTimer_Tick(t *testing.T) {

require.NoError(t, err)

for i := 0; i < int(test.duration); i++ {
for range test.duration {
if !timer.Tick() {
break
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/nspcc-dev/neofs-node

go 1.21
go 1.22

require (
github.com/cheggaaa/pb v1.0.29
Expand Down
2 changes: 1 addition & 1 deletion pkg/core/object/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func (v *FormatValidator) ValidateContent(o *object.Object) (ContentMeta, error)

uniqueFilter := make(map[oid.ID]struct{}, lenMM)

for i := 0; i < lenMM; i++ {
for i := range lenMM {
if _, alreadySeen := uniqueFilter[mm[i]]; alreadySeen {
return ContentMeta{}, fmt.Errorf("storage group contains non-unique member: %s", mm[i])
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/innerring/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func parseAlphabetContracts(ctx *nnsContext, _logger *zap.Logger, cfg *viper.Vip
num = glagolitsa.Size
}

for ind := 0; ind < num; ind++ {
for ind := range num {
letter := glagolitsa.LetterByIndex(ind)
contractHash, err := parseContract(ctx, _logger, cfg, morph,
"contracts.alphabet."+letter,
Expand Down
8 changes: 4 additions & 4 deletions pkg/innerring/processors/audit/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestSelect(t *testing.T) {

m := hitMap(cids)

for i := 0; i < irSize; i++ {
for i := range irSize {
s := audit.Select(cids, 0, uint64(i), irSize)
require.Equal(t, len(cids)/irSize, len(s))

Expand All @@ -41,7 +41,7 @@ func TestSelect(t *testing.T) {

m := hitMap(cids)

for i := 0; i < irSize; i++ {
for i := range irSize {
s := audit.Select(cids, 0, uint64(i), irSize)

for _, id := range s {
Expand All @@ -60,7 +60,7 @@ func TestSelect(t *testing.T) {

m := hitMap(cids)

for i := 0; i < irSize; i++ {
for i := range irSize {
s := audit.Select(cids, uint64(i), 0, irSize)

for _, id := range s {
Expand All @@ -78,7 +78,7 @@ func TestSelect(t *testing.T) {
func generateContainers(n int) []cid.ID {
result := make([]cid.ID, n)

for i := 0; i < n; i++ {
for i := range n {
result[i] = cidtest.ID()
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/innerring/processors/governance/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestNewAlphabetList(t *testing.T) {
}
ln := len(rounds)

for i := 0; i < ln; i++ {
for i := range ln {
list, err = newAlphabetList(list, exp)
require.NoError(t, err)
require.True(t, equalPublicKeyLists(list, rounds[i]))
Expand Down Expand Up @@ -132,7 +132,7 @@ func TestUpdateInnerRing(t *testing.T) {
func generateKeys(n int) (keys.PublicKeys, error) {
pubKeys := make(keys.PublicKeys, 0, n)

for i := 0; i < n; i++ {
for range n {
privKey, err := keys.NewPrivateKey()
if err != nil {
return nil, err
Expand Down
12 changes: 6 additions & 6 deletions pkg/local_object_storage/blobstor/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ func benchmark(b *testing.B, p common.Storage, objSize uint64, nThreads int) {

b.ResetTimer()

for i := 0; i < b.N; i++ {
for range b.N {
var wg sync.WaitGroup

for i := 0; i < nThreads; i++ {
for range nThreads {
wg.Add(1)
go func() {
defer wg.Done()
Expand Down Expand Up @@ -140,7 +140,7 @@ func BenchmarkGet(b *testing.B) {
}

var ach = make(chan oid.Address)
for i := 0; i < 100; i++ {
for range 100 {
go func() {
for j := 0; j < nObjects/100; j++ {
prm := prm
Expand All @@ -153,16 +153,16 @@ func BenchmarkGet(b *testing.B) {
}
}()
}
for i := 0; i < nObjects; i++ {
for range nObjects {
a := <-ach
objs = append(objs, a)
}

b.ResetTimer()
for n := 0; n < b.N; n++ {
for n := range b.N {
var wg sync.WaitGroup

for i := 0; i < tc.nThreads; i++ {
for i := range tc.nThreads {
wg.Add(1)
go func(ind int) {
defer wg.Done()
Expand Down
2 changes: 1 addition & 1 deletion pkg/local_object_storage/blobstor/blobstor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestCompression(t *testing.T) {

bigObj := make([]*objectSDK.Object, objCount)
smallObj := make([]*objectSDK.Object, objCount)
for i := 0; i < objCount; i++ {
for i := range objCount {
bigObj[i] = testObject(smallSizeLimit * 2)
smallObj[i] = testObject(smallSizeLimit / 2)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/local_object_storage/blobstor/common/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestCopy(t *testing.T) {

mObjs := make(map[oid.Address][]byte, nObjects)

for i := 0; i < nObjects; i++ {
for range nObjects {
addr := oidtest.Address()
data := make([]byte, 32)
rand.Read(data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func BenchmarkCompression(b *testing.B) {
func benchWith(b *testing.B, c Config, data []byte) {
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
_ = c.Compress(data)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (w *genericWriter) writeData(_ oid.ID, p string, data []byte) error {
// In a very rare situation we can have multiple partially written copies on disk,
// this will be fixed in another issue (we should remove garbage on start).
const retryCount = 5
for i := 0; i < retryCount; i++ {
for i := range retryCount {
tmpPath := p + "#" + strconv.FormatUint(uint64(i), 10)
err := w.writeAndRename(tmpPath, p, data)
if err != syscall.EEXIST || i == retryCount-1 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/local_object_storage/blobstor/iterate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func TestIterate_IgnoreErrors(t *testing.T) {
//require.NoError(t, b.Init())
//
//var p string
//for i := 0; i < 2; i++ {
//for i := range 2 {
// bp := filepath.Join(bs.rootPath, "1", strconv.FormatUint(uint64(i), 10))
// if _, ok := bs.blobovniczas.opened.Get(bp); !ok {
// p = bp
Expand Down
2 changes: 1 addition & 1 deletion pkg/local_object_storage/engine/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestStorageEngine_ContainerCleanUp(t *testing.T) {
_ = e.Close()
})

for i := 0; i < 5; i++ {
for i := range 5 {
_, err := e.AddShard(
shard.WithBlobStorOptions(
blobstor.WithStorages(newStorages(filepath.Join(path, strconv.Itoa(i)), errSmallSize))),
Expand Down
2 changes: 1 addition & 1 deletion pkg/local_object_storage/engine/control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func engineWithShards(t *testing.T, path string, num int) (*StorageEngine, []str
currShards := make([]string, 0, num)

e := New()
for i := 0; i < num; i++ {
for i := range num {
id, err := e.AddShard(
shard.WithBlobStorOptions(
blobstor.WithStorages(newStorages(filepath.Join(addPath, strconv.Itoa(i)), errSmallSize))),
Expand Down
10 changes: 5 additions & 5 deletions pkg/local_object_storage/engine/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func BenchmarkExists(b *testing.B) {

func benchmarkExists(b *testing.B, shardNum int) {
shards := make([]*shard.Shard, shardNum)
for i := 0; i < shardNum; i++ {
for i := range shardNum {
shards[i] = testNewShard(b, i)
}

Expand All @@ -62,7 +62,7 @@ func benchmarkExists(b *testing.B, shardNum int) {
})

addr := oidtest.Address()
for i := 0; i < 100; i++ {
for range 100 {
obj := generateObjectWithCID(b, cidtest.ID())
err := Put(e, obj)
if err != nil {
Expand All @@ -72,7 +72,7 @@ func benchmarkExists(b *testing.B, shardNum int) {

b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
for range b.N {
ok, err := e.exists(addr)
if err != nil || ok {
b.Fatalf("%t %v", ok, err)
Expand Down Expand Up @@ -149,7 +149,7 @@ func testNewShard(t testing.TB, id int) *shard.Shard {

func testEngineFromShardOpts(t *testing.T, num int, extraOpts []shard.Option) *StorageEngine {
engine := New()
for i := 0; i < num; i++ {
for i := range num {
_, err := engine.AddShard(append([]shard.Option{
shard.WithBlobStorOptions(
blobstor.WithStorages(
Expand Down Expand Up @@ -210,7 +210,7 @@ func addAttribute(obj *object.Object, key, val string) {
func testNewEngineWithShardNum(t *testing.T, num int) *StorageEngine {
shards := make([]*shard.Shard, 0, num)

for i := 0; i < num; i++ {
for i := range num {
shards = append(shards, testNewShard(t, i))
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/local_object_storage/engine/gc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestChildrenExpiration(t *testing.T) {
owner := usertest.ID()

e := New()
for i := 0; i < numOfShards; i++ {
for i := range numOfShards {
_, err := e.AddShard(
shard.WithBlobStorOptions(
blobstor.WithStorages(
Expand Down
Loading

0 comments on commit d214b0c

Please sign in to comment.