Skip to content

Commit 41e3237

Browse files
authored
Merge pull request #582 from onflow/fxamacker/bump-go-version-to-1.24
Bump Go and linter versions and update the code
2 parents b3a14f0 + 11747fb commit 41e3237

31 files changed

+2374
-2365
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
strategy:
3636
matrix:
3737
os: [ubuntu-latest]
38-
go-version: ['1.23', '1.24']
38+
go-version: ['1.24', '1.25']
3939

4040
steps:
4141
- name: Install Go

.github/workflows/safer-golangci-lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ on:
2323
- 'release-**'
2424

2525
env:
26-
GO_VERSION: '1.23'
27-
GOLINTERS_VERSION: 1.63.4
26+
GO_VERSION: '1.24'
27+
GOLINTERS_VERSION: 2.5.0
2828
GOLINTERS_ARCH: linux-amd64
29-
GOLINTERS_TGZ_DGST: 01abb14a4df47b5ca585eff3c34b105023cba92ec34ff17212dbb83855581690
29+
GOLINTERS_TGZ_DGST: c77313a77e19b06123962c411d9943cc0d092bbec76b956104d18964e274902e
3030
GOLINTERS_TIMEOUT: 15m
3131
OPENSSL_DGST_CMD: openssl dgst -sha256 -r
3232
CURL_CMD: curl --proto =https --tlsv1.2 --location --silent --show-error --fail

.golangci.yml

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,52 @@
1-
# .golangci.yml for github.com/onflow/atree
2-
1+
version: "2"
32
linters:
4-
disable-all: true
3+
default: none
54
enable:
65
- asciicheck
76
- bidichk
87
- copyloopvar
98
- errcheck
10-
# - forbidigo # TODO: enable forbidigo after adding non-default settings
119
- gocritic
12-
- gofmt
13-
- goimports
14-
- gosimple
1510
- govet
1611
- ineffassign
1712
- misspell
1813
- nilerr
14+
- revive
1915
- staticcheck
20-
- typecheck
2116
- unconvert
2217
- unused
23-
18+
settings:
19+
gocritic:
20+
disabled-checks:
21+
- ifElseChain
22+
- singleCaseSwitch
23+
- commentFormatting
24+
- exitAfterDefer
25+
exclusions:
26+
generated: lax
27+
presets:
28+
- comments
29+
- common-false-positives
30+
- legacy
31+
- std-error-handling
32+
paths:
33+
- third_party$
34+
- builtin$
35+
- examples$
2436
issues:
2537
max-issues-per-linter: 0
2638
max-same-issues: 0
27-
28-
linters-settings:
29-
gocritic:
30-
disabled-checks:
31-
- ifElseChain # style
32-
- singleCaseSwitch # style
33-
- unslice # false positives
34-
- commentFormatting # does not detect commented out code
35-
- exitAfterDefer
36-
37-
goimports:
38-
local-prefixes: github.com/onflow/atree
39+
formatters:
40+
enable:
41+
- gofmt
42+
- goimports
43+
settings:
44+
goimports:
45+
local-prefixes:
46+
- github.com/onflow/atree
47+
exclusions:
48+
generated: lax
49+
paths:
50+
- third_party$
51+
- builtin$
52+
- examples$

array_bench_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"github.com/stretchr/testify/require"
2626

2727
"github.com/onflow/atree"
28-
"github.com/onflow/atree/test_utils"
28+
testutils "github.com/onflow/atree/test_utils"
2929
)
3030

3131
var noopValue atree.Value
@@ -193,7 +193,7 @@ func setupArray(b *testing.B, r *rand.Rand, storage *atree.PersistentSlabStorage
193193

194194
address := atree.Address{1, 2, 3, 4, 5, 6, 7, 8}
195195

196-
typeInfo := test_utils.NewSimpleTypeInfo(42)
196+
typeInfo := testutils.NewSimpleTypeInfo(42)
197197

198198
array, err := atree.NewArray(storage, address, typeInfo)
199199
require.NoError(b, err)
@@ -231,7 +231,7 @@ func benchmarkArrayGet(b *testing.B, initialArrayCount, numberOfOps int) {
231231

232232
b.StartTimer()
233233

234-
for range b.N {
234+
for b.Loop() {
235235
for range numberOfOps {
236236
index := getRandomArrayIndex(r, array)
237237
value, _ = array.Get(index)
@@ -249,7 +249,7 @@ func benchmarkArrayInsert(b *testing.B, initialArrayCount, numberOfOps int) {
249249

250250
storage := newTestPersistentStorage(b)
251251

252-
for range b.N {
252+
for b.Loop() {
253253

254254
b.StopTimer()
255255

@@ -273,7 +273,7 @@ func benchmarkArrayRemove(b *testing.B, initialArrayCount, numberOfOps int) {
273273

274274
storage := newTestPersistentStorage(b)
275275

276-
for range b.N {
276+
for b.Loop() {
277277

278278
b.StopTimer()
279279

@@ -298,7 +298,7 @@ func benchmarkArrayRemoveAll(b *testing.B, initialArrayCount int) {
298298

299299
var storable atree.Storable
300300

301-
for range b.N {
301+
for b.Loop() {
302302

303303
b.StopTimer()
304304

@@ -324,7 +324,7 @@ func benchmarkArrayPopIterate(b *testing.B, initialArrayCount int) {
324324

325325
var storable atree.Storable
326326

327-
for range b.N {
327+
for b.Loop() {
328328

329329
b.StopTimer()
330330

@@ -355,7 +355,7 @@ func benchmarkNewArrayFromAppend(b *testing.B, initialArrayCount int) {
355355

356356
b.StartTimer()
357357

358-
for range b.N {
358+
for b.Loop() {
359359
copied, _ := atree.NewArray(storage, array.Address(), array.Type())
360360

361361
_ = array.IterateReadOnly(func(value atree.Value) (bool, error) {
@@ -381,7 +381,7 @@ func benchmarkNewArrayFromBatchData(b *testing.B, initialArrayCount int) {
381381

382382
b.StartTimer()
383383

384-
for range b.N {
384+
for b.Loop() {
385385
iter, err := array.ReadOnlyIterator()
386386
require.NoError(b, err)
387387

array_benchmark_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"github.com/stretchr/testify/require"
2626

2727
"github.com/onflow/atree"
28-
"github.com/onflow/atree/test_utils"
28+
testutils "github.com/onflow/atree/test_utils"
2929
)
3030

3131
// GENERAL COMMENT:
@@ -58,7 +58,7 @@ func benchmarkArray(b *testing.B, initialArrayCount, numberOfElements int) {
5858

5959
address := atree.Address{1, 2, 3, 4, 5, 6, 7, 8}
6060

61-
typeInfo := test_utils.NewSimpleTypeInfo(42)
61+
typeInfo := testutils.NewSimpleTypeInfo(42)
6262

6363
array, err := atree.NewArray(storage, address, typeInfo)
6464

@@ -191,7 +191,7 @@ func benchmarkLongTermImpactOnMemory(b *testing.B, initialArrayCount, numberOfOp
191191

192192
address := atree.Address{1, 2, 3, 4, 5, 6, 7, 8}
193193

194-
typeInfo := test_utils.NewSimpleTypeInfo(42)
194+
typeInfo := testutils.NewSimpleTypeInfo(42)
195195

196196
array, err := atree.NewArray(storage, address, typeInfo)
197197

array_slab_stats.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ package atree
2020

2121
import "fmt"
2222

23-
type arrayStats struct {
23+
type ArrayStats struct {
2424
Levels uint64
2525
ElementCount uint64
2626
MetaDataSlabCount uint64
2727
DataSlabCount uint64
2828
StorableSlabCount uint64
2929
}
3030

31-
func (s *arrayStats) SlabCount() uint64 {
31+
func (s *ArrayStats) SlabCount() uint64 {
3232
return s.DataSlabCount + s.MetaDataSlabCount + s.StorableSlabCount
3333
}
3434

3535
// GetArrayStats returns stats about array slabs.
36-
func GetArrayStats(a *Array) (arrayStats, error) {
36+
func GetArrayStats(a *Array) (ArrayStats, error) {
3737
level := uint64(0)
3838
metaDataSlabCount := uint64(0)
3939
dataSlabCount := uint64(0)
@@ -52,7 +52,7 @@ func GetArrayStats(a *Array) (arrayStats, error) {
5252
slab, err := getArraySlab(a.Storage, id)
5353
if err != nil {
5454
// Don't need to wrap error as external error because err is already categorized by getArraySlab().
55-
return arrayStats{}, err
55+
return ArrayStats{}, err
5656
}
5757

5858
switch slab.(type) {
@@ -68,7 +68,7 @@ func GetArrayStats(a *Array) (arrayStats, error) {
6868
for _, storable := range slab.ChildStorables() {
6969
id, ok := storable.(SlabIDStorable)
7070
if !ok {
71-
return arrayStats{}, NewFatalError(fmt.Errorf("metadata slab's child storables are not of type SlabIDStorable"))
71+
return ArrayStats{}, NewFatalError(fmt.Errorf("metadata slab's child storables are not of type SlabIDStorable"))
7272
}
7373
nextLevelIDs = append(nextLevelIDs, SlabID(id))
7474
}
@@ -79,7 +79,7 @@ func GetArrayStats(a *Array) (arrayStats, error) {
7979

8080
}
8181

82-
return arrayStats{
82+
return ArrayStats{
8383
Levels: level,
8484
ElementCount: a.Count(),
8585
MetaDataSlabCount: metaDataSlabCount,

0 commit comments

Comments
 (0)