From 1f8a255890d3467d38b441e7b0223de661a60882 Mon Sep 17 00:00:00 2001 From: Ajat Prabha Date: Tue, 16 Jul 2024 11:51:24 +0530 Subject: [PATCH] Support wrapped err check using errors.Is (#8) * chore: use errors.Is to support wrapped errors * ci: add go 1.21.x, 1.22.x to test matrix --- .github/workflows/test.yaml | 2 +- component/http_server.go | 3 ++- component/x/grpc/server.go | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 462d6a0..f8c1de2 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go-version: [1.19.x, 1.20.x] + go-version: [1.19.x, 1.20.x, 1.21.x, 1.22.x] steps: - name: Install Go uses: actions/setup-go@v4 diff --git a/component/http_server.go b/component/http_server.go index 7d18d80..b79adaf 100644 --- a/component/http_server.go +++ b/component/http_server.go @@ -2,6 +2,7 @@ package component import ( "context" + "errors" "net/http" "github.com/gojekfarm/xrun" @@ -28,7 +29,7 @@ func HTTPServer(opts HTTPServerOptions) xrun.ComponentFunc { ps() } - if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { + if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) { errCh <- err } }() diff --git a/component/x/grpc/server.go b/component/x/grpc/server.go index a1d197f..552b0d2 100644 --- a/component/x/grpc/server.go +++ b/component/x/grpc/server.go @@ -2,6 +2,7 @@ package grpc import ( "context" + "errors" "net" "google.golang.org/grpc" @@ -39,7 +40,7 @@ func Server(opts Options) xrun.ComponentFunc { ps() } - if err := srv.Serve(l); err != nil && err != grpc.ErrServerStopped { + if err := srv.Serve(l); err != nil && !errors.Is(err, grpc.ErrServerStopped) { errCh <- err } }(errCh)