From b4b2b03737da6747906c2d705628e75107124c7d Mon Sep 17 00:00:00 2001 From: Daniel Gordos Date: Tue, 24 Feb 2026 14:20:22 +1100 Subject: [PATCH] chore: update go to 1.26.0 and golangci-lint to v2.10.1 --- Dockerfile | 2 +- Makefile | 11 ++++-- go.mod | 2 +- pkg/logger/chunking_test.go | 2 +- pkg/logger/fields.go | 10 +++--- pkg/logger/fields_test.go | 66 +++++++++++++++++------------------ pkg/logger/nullify_context.go | 4 +-- pkg/logger/tracer/lambda.go | 2 +- tests/add_field_test.go | 2 +- tests/production_test.go | 2 +- 10 files changed, 54 insertions(+), 49 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8fa1530..11a4049 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1 +1 @@ -FROM golangci/golangci-lint:v2.8.0@sha256:bebcfa63db7df53e417845ed61e4540519cf74fcba22793cdd174b3415a9e4e2 AS golangci-lint +FROM golangci/golangci-lint:v2.10.1@sha256:ea84d14c2fef724411be7dc45e09e6ef721d748315252b02df19a7e3113ee763 AS golangci-lint diff --git a/Makefile b/Makefile index 93ae92b..91cf60a 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ VERSION ?= $(shell git rev-list -1 HEAD) GOENV = CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOFLAGS = -ldflags "-X 'moseisleycantina/internal/logger.Version=$(VERSION)'" +GOLANGCI_LINT_VERSION := v2.10.1 build: $(GOENV) go build $(GOFLAGS) -o bin/logger ./cmd/... @@ -22,9 +23,13 @@ cov: -go tool cover -html=coverage.txt -o coverage.html -go tool cover -func=coverage.txt -lint: - docker build --quiet --target golangci-lint -t golangci-lint:latest . - docker run --rm -v $(shell pwd):/app -w /app golangci-lint golangci-lint run ./... +lint: lint-go + +lint-go: + @if ! command -v golangci-lint >/dev/null 2>&1 || ! golangci-lint version 2>/dev/null | grep -q "$(patsubst v%,%,$(GOLANGCI_LINT_VERSION))"; then \ + go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) ; \ + fi + golangci-lint run ./... lint-python: ruff format pylogtracer --check diff --git a/go.mod b/go.mod index a2aa129..7d87a18 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/nullify-platform/logger -go 1.24.5 +go 1.26.0 require go.uber.org/multierr v1.11.0 // indirect diff --git a/pkg/logger/chunking_test.go b/pkg/logger/chunking_test.go index 1b67f9e..4620920 100644 --- a/pkg/logger/chunking_test.go +++ b/pkg/logger/chunking_test.go @@ -135,7 +135,7 @@ func TestChunkOversizedFields_ExactLimit(t *testing.T) { } // fieldsToMap converts a slice of zap fields to a map for easier test assertions. -func fieldsToMap(fields []zapcore.Field) map[string]interface{} { +func fieldsToMap(fields []zapcore.Field) map[string]any { enc := zapcore.NewMapObjectEncoder() for _, f := range fields { f.AddTo(enc) diff --git a/pkg/logger/fields.go b/pkg/logger/fields.go index 45d630f..f181c0b 100644 --- a/pkg/logger/fields.go +++ b/pkg/logger/fields.go @@ -18,7 +18,7 @@ func Trace(trace []byte) Field { } // Any adds a field to the logger -func Any(key string, val interface{}) Field { +func Any(key string, val any) Field { return zap.Any(key, val) } @@ -157,7 +157,7 @@ type ToolCallFields struct { // WithAgent adds agent-related fields to the log entry func WithAgent(agent AgentFields) Field { - fields := map[string]interface{}{ + fields := map[string]any{ "name": agent.Name, "status": agent.Status, } @@ -178,7 +178,7 @@ func (a *AgentFields) WithTraceID(traceID string) *AgentFields { // WithRepository adds repository-related fields to the log entry func WithRepository(repo RepositoryFields) Field { - fields := map[string]interface{}{ + fields := map[string]any{ "name": repo.Name, "platform": repo.Platform, "installation_id": repo.InstallationID, @@ -193,7 +193,7 @@ func WithRepository(repo RepositoryFields) Field { // WithService adds service-related fields to the log entry func WithService(service ServiceFields) Field { - fields := map[string]interface{}{ + fields := map[string]any{ "name": service.Name, } @@ -225,7 +225,7 @@ func WithErrorInfo(errFields ErrorFields) []Field { } func WithToolCall(toolCall ToolCallFields) Field { - fields := map[string]interface{}{ + fields := map[string]any{ "tool_name": toolCall.ToolName, "status": toolCall.Status, } diff --git a/pkg/logger/fields_test.go b/pkg/logger/fields_test.go index 7d8b3c5..2f42637 100644 --- a/pkg/logger/fields_test.go +++ b/pkg/logger/fields_test.go @@ -11,7 +11,7 @@ func TestLogFields(t *testing.T) { tests := []struct { name string builder func() []Field - expected map[string]interface{} + expected map[string]any }{ { name: "agent fields", @@ -20,8 +20,8 @@ func TestLogFields(t *testing.T) { WithAgent("test-agent", "running"). Build() }, - expected: map[string]interface{}{ - "agent": map[string]interface{}{ + expected: map[string]any{ + "agent": map[string]any{ "name": "test-agent", "status": "running", }, @@ -34,8 +34,8 @@ func TestLogFields(t *testing.T) { WithService("test-service"). Build() }, - expected: map[string]interface{}{ - "service": map[string]interface{}{ + expected: map[string]any{ + "service": map[string]any{ "name": "test-service", }, }, @@ -49,8 +49,8 @@ func TestLogFields(t *testing.T) { WithServiceCategory("test-category"). Build() }, - expected: map[string]interface{}{ - "service": map[string]interface{}{ + expected: map[string]any{ + "service": map[string]any{ "name": "test-service", "tool_name": "test-tool", "tool_version": "1.0.0", @@ -65,8 +65,8 @@ func TestLogFields(t *testing.T) { WithRepository("test-repo", "github", "12345"). Build() }, - expected: map[string]interface{}{ - "repository": map[string]interface{}{ + expected: map[string]any{ + "repository": map[string]any{ "name": "test-repo", "platform": "github", "installation_id": "12345", @@ -81,8 +81,8 @@ func TestLogFields(t *testing.T) { WithRepositoryOwner("test-owner"). Build() }, - expected: map[string]interface{}{ - "repository": map[string]interface{}{ + expected: map[string]any{ + "repository": map[string]any{ "name": "test-repo", "platform": "github", "installation_id": "12345", @@ -97,7 +97,7 @@ func TestLogFields(t *testing.T) { WithError(ErrorTypeAgent, "test error"). Build() }, - expected: map[string]interface{}{ + expected: map[string]any{ "error_type": "agent_error", "error_message": "test error", }, @@ -110,7 +110,7 @@ func TestLogFields(t *testing.T) { WithErrorTraceback("test traceback"). Build() }, - expected: map[string]interface{}{ + expected: map[string]any{ "error_type": "agent_error", "error_message": "test error", "error_traceback": "test traceback", @@ -123,8 +123,8 @@ func TestLogFields(t *testing.T) { WithToolCallInfo("api_call", "failed"). Build() }, - expected: map[string]interface{}{ - "tool_call": map[string]interface{}{ + expected: map[string]any{ + "tool_call": map[string]any{ "tool_name": "api_call", "status": "failed", }, @@ -138,8 +138,8 @@ func TestLogFields(t *testing.T) { WithToolCallErrorReason("connection timeout"). Build() }, - expected: map[string]interface{}{ - "tool_call": map[string]interface{}{ + expected: map[string]any{ + "tool_call": map[string]any{ "tool_name": "api_call", "status": "failed", "error_reason": "connection timeout", @@ -154,8 +154,8 @@ func TestLogFields(t *testing.T) { WithToolCallDuration(1500). Build() }, - expected: map[string]interface{}{ - "tool_call": map[string]interface{}{ + expected: map[string]any{ + "tool_call": map[string]any{ "tool_name": "api_call", "status": "failed", "duration_ms": int64(1500), @@ -171,8 +171,8 @@ func TestLogFields(t *testing.T) { WithToolCallDuration(1500). Build() }, - expected: map[string]interface{}{ - "tool_call": map[string]interface{}{ + expected: map[string]any{ + "tool_call": map[string]any{ "tool_name": "api_call", "status": "failed", "error_reason": "connection timeout", @@ -190,12 +190,12 @@ func TestLogFields(t *testing.T) { WithError(ErrorTypeToolCall, "tool execution failed"). Build() }, - expected: map[string]interface{}{ - "agent": map[string]interface{}{ + expected: map[string]any{ + "agent": map[string]any{ "name": "executor-agent", "status": "executing", }, - "tool_call": map[string]interface{}{ + "tool_call": map[string]any{ "tool_name": "api_call", "status": "failed", "error_reason": "timeout", @@ -218,18 +218,18 @@ func TestLogFields(t *testing.T) { WithErrorTraceback("test traceback"). Build() }, - expected: map[string]interface{}{ - "agent": map[string]interface{}{ + expected: map[string]any{ + "agent": map[string]any{ "name": "test-agent", "status": "failed", }, - "service": map[string]interface{}{ + "service": map[string]any{ "name": "test-service", "tool_name": "test-tool", "tool_version": "1.0.0", "category": "test-category", }, - "repository": map[string]interface{}{ + "repository": map[string]any{ "name": "test-repo", "platform": "github", "installation_id": "12345", @@ -254,20 +254,20 @@ func TestLogFields(t *testing.T) { WithErrorTraceback("goroutine trace..."). Build() }, - expected: map[string]interface{}{ - "agent": map[string]interface{}{ + expected: map[string]any{ + "agent": map[string]any{ "name": "test-agent", "status": "executing", }, - "service": map[string]interface{}{ + "service": map[string]any{ "name": "tool-executor", }, - "repository": map[string]interface{}{ + "repository": map[string]any{ "name": "test-repo", "platform": "github", "installation_id": "12345", }, - "tool_call": map[string]interface{}{ + "tool_call": map[string]any{ "tool_name": "api_call", "status": "failed", "error_reason": "timeout", diff --git a/pkg/logger/nullify_context.go b/pkg/logger/nullify_context.go index 526ce31..db6f02c 100644 --- a/pkg/logger/nullify_context.go +++ b/pkg/logger/nullify_context.go @@ -117,7 +117,7 @@ func extractFieldsFromStruct(ctx context.Context, v reflect.Value, fields []zapc return fields } - if v.Kind() == reflect.Ptr { + if v.Kind() == reflect.Pointer { v = v.Elem() } @@ -133,7 +133,7 @@ func extractFieldsFromStruct(ctx context.Context, v reflect.Value, fields []zapc fieldValue := v.Field(i) // If the field is a struct, recurse into it - if fieldValue.Kind() == reflect.Struct || (fieldValue.Kind() == reflect.Ptr && fieldValue.Elem().Kind() == reflect.Struct) { + if fieldValue.Kind() == reflect.Struct || (fieldValue.Kind() == reflect.Pointer && fieldValue.Elem().Kind() == reflect.Struct) { fields = extractFieldsFromStruct(ctx, fieldValue, fields) continue } diff --git a/pkg/logger/tracer/lambda.go b/pkg/logger/tracer/lambda.go index 474c8c9..d54fa4f 100644 --- a/pkg/logger/tracer/lambda.go +++ b/pkg/logger/tracer/lambda.go @@ -40,7 +40,7 @@ func CreateClientContextForLambdaInvoke(ctx context.Context, custom map[string]s InjectTracingIntoCustomMessage(ctx, custom) var clientContextBase64 *string - if marshalled, err := json.Marshal(map[string]interface{}{"custom": custom}); err == nil { + if marshalled, err := json.Marshal(map[string]any{"custom": custom}); err == nil { clientContextJSON := marshalled clientContextBase64 = aws.String(base64.StdEncoding.EncodeToString(clientContextJSON)) } diff --git a/tests/add_field_test.go b/tests/add_field_test.go index cf20d6e..56a85c2 100644 --- a/tests/add_field_test.go +++ b/tests/add_field_test.go @@ -28,7 +28,7 @@ func TestAddField(t *testing.T) { fmt.Println("stdout: " + output.String()) // check that the output doesn't include the added field - var jsonOutput map[string]interface{} + var jsonOutput map[string]any err = json.Unmarshal(output.Bytes(), &jsonOutput) require.Nil(t, err) _, ok := jsonOutput["my"] diff --git a/tests/production_test.go b/tests/production_test.go index eb6a43e..e456e70 100644 --- a/tests/production_test.go +++ b/tests/production_test.go @@ -28,7 +28,7 @@ func TestProductionLogger(t *testing.T) { fmt.Println("stdout: " + output.String()) - var jsonOutput map[string]interface{} + var jsonOutput map[string]any err = json.Unmarshal(output.Bytes(), &jsonOutput) require.Nil(t, err, "stdout was not valid json")