Skip to content

Commit f198c78

Browse files
committed
updated go and lint version
1 parent 48f97f4 commit f198c78

File tree

14 files changed

+46
-23
lines changed

14 files changed

+46
-23
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
- name: Lint Go
9696
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
9797
with:
98-
version: v2.4.0
98+
version: v2.10.0
9999
skip-cache: true
100100

101101
vulnerability-scan:

Makefile.tools

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
OAPICODEGEN = github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@v2.1.0
22
LEFTHOOK = github.com/evilmartians/lefthook@v1.6.9
3-
GOLANGCILINT = github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.4.0
3+
GOLANGCILINT = github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.10.0
44
PROTOCGENGO = google.golang.org/protobuf/cmd/protoc-gen-go@v1.32.0
55
GOFUMPT = mvdan.cc/gofumpt@v0.6.0
66
COUNTERFEITER = github.com/maxbrunsfeld/counterfeiter/v6@v6.8.1

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/nginx/agent/v3
22

3-
go 1.24.2
4-
5-
toolchain go1.24.13
3+
go 1.25.7
64

75
require (
86
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.9-20250912141014-52f32327d4b0.1

internal/collector/containermetricsreceiver/internal/scraper/cpuscraper/internal/cgroup/cpu_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import (
1313
"strconv"
1414
"testing"
1515

16-
"github.com/stretchr/testify/assert"
16+
"github.com/pkg/errors"
17+
"github.com/stretchr/testify/require"
1718
)
1819

1920
func TestCollectCPUStats(t *testing.T) {
@@ -79,10 +80,18 @@ func TestCollectCPUStats(t *testing.T) {
7980
cpuStat, err := cgroupCPUSource.collectCPUStats(ctx)
8081

8182
// Assert error
82-
assert.IsType(tt, test.errorType, err)
83+
if test.errorType == nil {
84+
require.NoError(tt, err)
85+
} else {
86+
require.Error(tt, err)
87+
// satisfy the linter's requirement for a more specific check than IsType.
88+
require.Condition(tt, func() bool {
89+
return errors.As(err, &test.errorType)
90+
}, "Error should be of type %T", test.errorType)
91+
}
8392

8493
// Assert result
85-
assert.Equal(tt, test.cpuStat, cpuStat)
94+
require.Equal(tt, test.cpuStat, cpuStat)
8695
})
8796
}
8897
}

internal/collector/containermetricsreceiver/internal/scraper/memoryscraper/internal/cgroup/memory_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ import (
1313
"strconv"
1414
"testing"
1515

16+
"github.com/pkg/errors"
1617
"github.com/shirou/gopsutil/v4/mem"
17-
"github.com/stretchr/testify/assert"
18+
"github.com/stretchr/testify/require"
1819
)
1920

2021
func TestVirtualMemoryStat(t *testing.T) {
@@ -115,10 +116,18 @@ func TestVirtualMemoryStat(t *testing.T) {
115116
virtualMemoryStat, err := cgroupCPUSource.VirtualMemoryStat()
116117

117118
// Assert error
118-
assert.IsType(tt, test.errorType, err)
119+
if test.errorType == nil {
120+
require.NoError(tt, err)
121+
} else {
122+
require.Error(tt, err)
123+
// satisfy the linter's requirement for a more specific check than IsType.
124+
require.Condition(tt, func() bool {
125+
return errors.As(err, &test.errorType)
126+
}, "Error should be of type %T", test.errorType)
127+
}
119128

120129
// Assert result
121-
assert.Equal(tt, test.virtualMemoryStat, *virtualMemoryStat)
130+
require.Equal(tt, test.virtualMemoryStat, *virtualMemoryStat)
122131
})
123132
}
124133
}

internal/collector/nginxreceiver/internal/scraper/accesslog/nginx_log_scraper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func NewScraper(
7474
mb := metadata.NewMetricsBuilder(cfg.MetricsBuilderConfig, settings)
7575
rb := mb.NewResourceBuilder()
7676

77-
operators := make([]operator.Config, 0)
77+
operators := make([]operator.Config, 0, len(cfg.AccessLogs))
7878

7979
for _, accessLog := range cfg.AccessLogs {
8080
logger.Info("Adding access log file operator", zap.String("file_path", accessLog.FilePath))

internal/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,7 @@ func resolveExtensions() Extensions {
14071407

14081408
func updateHeaders(headers []Header) []Header {
14091409
var err error
1410-
newHeaders := []Header{}
1410+
newHeaders := make([]Header, 0, len(headers))
14111411

14121412
for _, header := range headers {
14131413
value := header.Value

internal/config/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ func TestResolveExtensions(t *testing.T) {
977977
extension := resolveExtensions()
978978
require.NotNil(t, extension)
979979

980-
var result []string
980+
result := make([]string, 0, len(extension.HeadersSetter.Headers))
981981
for _, header := range extension.HeadersSetter.Headers {
982982
result = append(result, header.Value)
983983
}

internal/grpc/grpc_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,15 @@ func validateError(t *testing.T, validationError error, isErrorExpected bool) {
350350

351351
func Test_ValidateGrpcError(t *testing.T) {
352352
result := ValidateGrpcError(TestError{})
353-
assert.IsType(t, TestError{}, result)
353+
if result == nil {
354+
t.Fatalf("expected an error, got nil")
355+
}
356+
var te TestError
357+
require.ErrorAs(t, result, &te)
354358

355359
result = ValidateGrpcError(status.Errorf(codes.InvalidArgument, "error"))
356-
assert.IsType(t, &backoff.PermanentError{}, result)
360+
var pe *backoff.PermanentError
361+
require.ErrorAs(t, result, &pe)
357362
}
358363

359364
func Test_transportCredentials(t *testing.T) {

internal/watcher/credentials/credential_watcher_service_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func TestCredentialWatcherService_addWatcher(t *testing.T) {
104104
}
105105

106106
func TestCredentialWatcherService_watchFiles(t *testing.T) {
107-
var files []string
107+
files := make([]string, 0, 3)
108108

109109
ctx := context.Background()
110110
cws := NewCredentialWatcherService(types.AgentConfig(), model.Command)

0 commit comments

Comments
 (0)