diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 1624ceb..09e0d17 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -8,7 +8,7 @@ on: workflow_dispatch: env: - GO_VER: 1.25.7 + GO_VER: 1.26.0 GINKGO_VER: 2.27.3 jobs: @@ -54,9 +54,9 @@ jobs: go-version: ${{ env.GO_VER }} cache: false - name: golangci-lint - uses: golangci/golangci-lint-action@v8 + uses: golangci/golangci-lint-action@v9 with: - version: v2.5.0 + version: v2.9.0 skip-cache: true problem-matchers: true diff --git a/.golangci.yml b/.golangci.yml index 29a769d..3923ecf 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,7 +1,7 @@ version: "2" run: concurrency: 4 - go: "1.25" + go: "1.26" tests: false linters: default: none @@ -56,6 +56,7 @@ linters: - unparam - usestdlibvars - whitespace + - modernize settings: gosec: excludes: diff --git a/core/cachestub/batch_cache_stub.go b/core/cachestub/batch_cache_stub.go index 0c8c8eb..403f1f0 100644 --- a/core/cachestub/batch_cache_stub.go +++ b/core/cachestub/batch_cache_stub.go @@ -231,7 +231,8 @@ func (bs *BatchCacheStub) makeKeyByte( chaincodeName string, args [][]byte, ) string { - keys := []string{channel, chaincodeName} + keys := make([]string, 0, 2+len(args)) + keys = append(keys, channel, chaincodeName) for _, arg := range args { keys = append(keys, string(arg)) } @@ -243,7 +244,8 @@ func (bs *BatchCacheStub) makeKeyString( chaincodeName string, args []string, ) string { - keys := []string{channel, chaincodeName} + keys := make([]string, 0, 2+len(args)) + keys = append(keys, channel, chaincodeName) keys = append(keys, args...) return strings.Join(keys, "") } diff --git a/core/routing/reflect/reflect_funcs.go b/core/routing/reflect/reflect_funcs.go index 9d0306e..5be871d 100644 --- a/core/routing/reflect/reflect_funcs.go +++ b/core/routing/reflect/reflect_funcs.go @@ -11,9 +11,9 @@ import ( // containing the names of all methods that are defined on its type. This function only considers // exported methods (those starting with an uppercase letter) due to Go's visibility rules in reflection. func Methods(v any) []string { - methodNames := make([]string, 0) - t := reflect.TypeOf(v) + methodNames := make([]string, 0, t.NumMethod()) + for i := range t.NumMethod() { method := t.Method(i) methodNames = append(methodNames, method.Name) @@ -86,5 +86,6 @@ func MethodReturnsError(v any, method string) bool { return false } - return methodType.Out(numOut-1) == reflect.TypeOf((*error)(nil)).Elem() + // TODO: when i install version 1.26 everywhere, remove nolint + return methodType.Out(numOut-1) == reflect.TypeOf((*error)(nil)).Elem() //nolint:modernize } diff --git a/fixture/gost/go.mod b/fixture/gost/go.mod index c5f7814..80e7db1 100644 --- a/fixture/gost/go.mod +++ b/fixture/gost/go.mod @@ -1,5 +1,5 @@ module gost -go 1.25.7 +go 1.26.0 require github.com/ddulesov/gogost v1.0.0 diff --git a/mocks/grpc/mock_client_conn.go b/mocks/grpc/mock_client_conn.go index 800fc28..315bf71 100644 --- a/mocks/grpc/mock_client_conn.go +++ b/mocks/grpc/mock_client_conn.go @@ -42,7 +42,7 @@ func (m *MockClientConn) SetCaller(user *mocks.UserFoundation) *MockClientConn { } // Invoke performs a unary RPC and returns after the response is received into reply. -func (m *MockClientConn) Invoke(_ context.Context, method string, args interface{}, reply interface{}, _ ...grpc.CallOption) error { +func (m *MockClientConn) Invoke(_ context.Context, method string, args any, reply any, _ ...grpc.CallOption) error { if m.user == nil { return errors.New("caller not set") } diff --git a/mocks/multisigned_user.go b/mocks/multisigned_user.go index fb82dd8..5388800 100644 --- a/mocks/multisigned_user.go +++ b/mocks/multisigned_user.go @@ -50,7 +50,7 @@ func NewUserFoundationMultisigned(keyType pbfound.KeyType, n int) (*UserFoundati }) hashedAddr := sha3.Sum256(bytes.Join(binPubKeys, []byte(""))) - userMultisigned.AddressBase58Check = base58.CheckEncode(hashedAddr[1:], hashedAddr[0]) + userMultisigned.AddressBase58Check = base58.CheckEncode(hashedAddr[1:], hashedAddr[0]) //nolint:gosec userMultisigned.AddressBytes = hashedAddr[:] return userMultisigned, nil } diff --git a/test/integration/go.mod b/test/integration/go.mod index 24e48ef..22615b1 100644 --- a/test/integration/go.mod +++ b/test/integration/go.mod @@ -1,6 +1,6 @@ module github.com/anoideaopen/foundation/test/integration -go 1.25.7 +go 1.26.0 tool ( github.com/IBM/idemix/tools/idemixgen