diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b004c21..e6d29cf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,30 +13,10 @@ jobs: matrix: module: [ '', 'otlp', 'gcp', - 'grpc', 'examples/grpc' - ] - go-version: [ 'stable', 'oldstable' ] - name: Test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - cache-dependency-path: "**/go.sum" - - name: Race Test - run: go test -v -shuffle=on -count=10 -race ./... - working-directory: ${{ matrix.module }} - - name: Test - run: go test -shuffle=on -v ./... - working-directory: ${{ matrix.module }} - test-http: - strategy: - matrix: - module: [ + 'grpc', 'examples/grpc', 'http', 'examples/http' ] - go-version: [ 'stable' ] + go-version: [ 'stable', 'oldstable' ] name: Test runs-on: ubuntu-latest steps: @@ -55,7 +35,7 @@ jobs: if: ${{ always() }} runs-on: ubuntu-latest name: All Tests - needs: [test, test-http] + needs: test steps: - name: Check test matrix status if: ${{ needs.test.result != 'success' }} diff --git a/.golangci.yml b/.golangci.yml index ad140e2..b4a790e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,6 +16,10 @@ linters-settings: local-prefixes: github.com/nil-go/nilgo gomoddirectives: replace-local: true + gosec: + excludes: + # Flags for potentially-unsafe casting of ints, similar problem to globally-disabled G103 + - G115 govet: enable: - shadow @@ -38,7 +42,7 @@ linters: - canonicalheader - containedctx - contextcheck - # copyloopvar + - copyloopvar - cyclop - decorder # depguard @@ -51,7 +55,6 @@ linters: - errchkjson - errname - errorlint - - exportloopref - exhaustive # exhaustruct - fatcontext diff --git a/CHANGELOG.md b/CHANGELOG.md index 1acc3e9..684f2d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,14 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Removed + +- Remove support for Golang 1.21 (#122). + ## [0.2.0] - 2024-05-17 ### Added + - Support Open Telemetry with OTLP exporters (#61). ## [0.1.0] - 2024-05-07 diff --git a/examples/grpc/go.mod b/examples/grpc/go.mod index 6f28738..bedab55 100644 --- a/examples/grpc/go.mod +++ b/examples/grpc/go.mod @@ -1,6 +1,6 @@ module github.com/nil-go/nilgo/examples/grpc -go 1.21 +go 1.22 require ( cloud.google.com/go/compute/metadata v0.3.0 diff --git a/examples/http/cmd/main.go b/examples/http/cmd/main.go index 7309608..2a1697f 100644 --- a/examples/http/cmd/main.go +++ b/examples/http/cmd/main.go @@ -51,18 +51,20 @@ func main() { } }) server := &http.Server{ - Handler: otelhttp.NewHandler(mux, "", otelhttp.WithSpanNameFormatter(func(operation string, r *http.Request) string { - if operation != "" { - return operation - } + Handler: otelhttp.NewHandler(mux, "", otelhttp.WithSpanNameFormatter( + func(operation string, req *http.Request) string { + if operation != "" { + return operation + } - method := r.Method - if method == "" { - method = "GET" - } + method := req.Method + if method == "" { + method = "GET" + } - return method + " " + r.URL.Path - })), + return method + " " + req.URL.Path + }), + ), ReadTimeout: time.Second, } runs = append(runs, diff --git a/gcp/go.mod b/gcp/go.mod index 62cf161..4a1bc9f 100644 --- a/gcp/go.mod +++ b/gcp/go.mod @@ -1,6 +1,6 @@ module github.com/nil-go/nilgo/gcp -go 1.21 +go 1.22 require ( cloud.google.com/go/compute/metadata v0.5.0 diff --git a/go.mod b/go.mod index eaf1a71..663e774 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/nil-go/nilgo -go 1.21 +go 1.22 require ( go.opentelemetry.io/otel v1.29.0 diff --git a/grpc/go.mod b/grpc/go.mod index d77574d..23dc133 100644 --- a/grpc/go.mod +++ b/grpc/go.mod @@ -1,6 +1,6 @@ module github.com/nil-go/nilgo/grpc -go 1.21 +go 1.22 require ( github.com/nil-go/konf v1.2.2 diff --git a/grpc/internal/buffer_test.go b/grpc/internal/buffer_test.go index 4474c7d..a0a3bb6 100644 --- a/grpc/internal/buffer_test.go +++ b/grpc/internal/buffer_test.go @@ -45,8 +45,6 @@ level=ERROR msg=error } for _, testcase := range testcases { - testcase := testcase - t.Run(testcase.description, func(t *testing.T) { t.Parallel() @@ -97,8 +95,6 @@ level=ERROR msg=error } for _, testcase := range testcases { - testcase := testcase - t.Run(testcase.description, func(t *testing.T) { t.Parallel() @@ -178,7 +174,6 @@ func TestIsSamplingHandler(t *testing.T) { } for _, testcase := range testcases { - testcase := testcase t.Run(testcase.description, func(t *testing.T) { t.Parallel() diff --git a/grpc/internal/recovery_test.go b/grpc/internal/recovery_test.go index a6f0a05..649f0ea 100644 --- a/grpc/internal/recovery_test.go +++ b/grpc/internal/recovery_test.go @@ -45,8 +45,6 @@ func TestRecoveryUnaryInterceptor(t *testing.T) { } for _, testcase := range testcases { - testcase := testcase - t.Run(testcase.description, func(t *testing.T) { t.Parallel() @@ -95,15 +93,13 @@ func TestRecoveryStreamInterceptor(t *testing.T) { handler: func(any, grpc.ServerStream) error { panic("panic from handler") }, - log: `level=ERROR source=/recovery_test.go:96 msg="Panic Recovered" error="panic from handler" + log: `level=ERROR source=/recovery_test.go:94 msg="Panic Recovered" error="panic from handler" `, err: "rpc error: code = Internal desc = ", }, } for _, testcase := range testcases { - testcase := testcase - t.Run(testcase.description, func(t *testing.T) { t.Parallel() diff --git a/grpc/server.go b/grpc/server.go index d59e58b..f81a628 100644 --- a/grpc/server.go +++ b/grpc/server.go @@ -106,7 +106,6 @@ func Run(server *grpc.Server, opts ...Option) func(context.Context) error { //no var waitGroup sync.WaitGroup waitGroup.Add(len(option.addresses)) for _, addr := range option.addresses { - addr := addr go func() { defer waitGroup.Done() diff --git a/grpc/server_test.go b/grpc/server_test.go index a3cd0f9..f5fcfad 100644 --- a/grpc/server_test.go +++ b/grpc/server_test.go @@ -103,8 +103,6 @@ func TestRun(t *testing.T) { } for _, testcase := range testcases { - testcase := testcase - t.Run(testcase.description, func(t *testing.T) { t.Parallel() diff --git a/http/internal/buffer_test.go b/http/internal/buffer_test.go index b60fbdb..70f7739 100644 --- a/http/internal/buffer_test.go +++ b/http/internal/buffer_test.go @@ -47,8 +47,6 @@ level=ERROR msg=error } for _, testcase := range testcases { - testcase := testcase - t.Run(testcase.description, func(t *testing.T) { t.Parallel() @@ -127,7 +125,6 @@ func TestIsSamplingHandler(t *testing.T) { } for _, testcase := range testcases { - testcase := testcase t.Run(testcase.description, func(t *testing.T) { t.Parallel() diff --git a/http/internal/recovery_test.go b/http/internal/recovery_test.go index 238d7b2..4587c4e 100644 --- a/http/internal/recovery_test.go +++ b/http/internal/recovery_test.go @@ -40,8 +40,6 @@ func TestRecoveryInterceptor(t *testing.T) { } for _, testcase := range testcases { - testcase := testcase - t.Run(testcase.description, func(t *testing.T) { t.Parallel() diff --git a/http/server.go b/http/server.go index 2ed1767..533ba93 100644 --- a/http/server.go +++ b/http/server.go @@ -100,7 +100,6 @@ func Run(server *http.Server, opts ...Option) func(context.Context) error { //no } } for _, addr := range option.addresses { - addr := addr go func() { defer waitGroup.Done() diff --git a/otlp/go.mod b/otlp/go.mod index 7ca2e25..dc40818 100644 --- a/otlp/go.mod +++ b/otlp/go.mod @@ -1,6 +1,6 @@ module github.com/nil-go/nilgo/otlp -go 1.21 +go 1.22 require ( github.com/stretchr/testify v1.9.0 diff --git a/runner.go b/runner.go index 5138f81..0bb06e7 100644 --- a/runner.go +++ b/runner.go @@ -59,7 +59,6 @@ func (r Runner) Run(ctx context.Context, runs ...func(context.Context) error) er var waitGroup sync.WaitGroup waitGroup.Add(len(r.preRuns)) for _, run := range r.preRuns { - run := run preRuns = append(preRuns, func(ctx context.Context) error { waitGroup.Done() @@ -131,7 +130,6 @@ func parallel(ctx context.Context, runs ...func(context.Context) error) error { var waitGroup sync.WaitGroup waitGroup.Add(len(runs)) for _, run := range runs { - run := run go func() { defer waitGroup.Done() diff --git a/runner_test.go b/runner_test.go index baf29ee..f01e6ef 100644 --- a/runner_test.go +++ b/runner_test.go @@ -88,8 +88,6 @@ func TestRunner_Run(t *testing.T) { } for _, testcase := range testcases { - testcase := testcase - var ran bool t.Run(testcase.description, func(t *testing.T) { t.Parallel()