diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d736828..6905123 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,6 +9,7 @@ jobs: strategy: matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] + go: [1.18, 1.19] fail-fast: false steps: @@ -17,12 +18,12 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.17.1 + go-version: ${{ matrix.go }} - name: Setup gotestsum uses: autero1/action-gotestsum@v1.0.0 with: - gotestsum_version: 1.7.0 + gotestsum_version: 1.8.1 - name: Test run: gotestsum --format short-verbose -- -race -timeout=20m -coverprofile=coverage_txt -covermode=atomic ./... diff --git a/.golangci.yml b/.golangci.yml index 449a43c..4e1fc0c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -44,3 +44,5 @@ linters: - cyclop - errname - varnamelen + - exhaustruct + - maintidx diff --git a/api.go b/api.go index 854d6ee..77f1f92 100644 --- a/api.go +++ b/api.go @@ -99,6 +99,7 @@ func (m MethodNotAllowedError) MarshalJSON() ([]byte, error) { } func errorAsJSON(err Error) []byte { + //nolint:errchkjson b, _ := json.Marshal(struct { Code int32 `json:"code"` Message string `json:"message"` @@ -146,7 +147,7 @@ func ServeError(rw http.ResponseWriter, r *http.Request, err error) { ServeError(rw, r, nil) } case *MethodNotAllowedError: - rw.Header().Add("Allow", strings.Join(err.(*MethodNotAllowedError).Allowed, ",")) + rw.Header().Add("Allow", strings.Join(e.Allowed, ",")) rw.WriteHeader(asHTTPCode(int(e.Code()))) if r == nil || r.Method != http.MethodHead { _, _ = rw.Write(errorAsJSON(e)) diff --git a/doc.go b/doc.go index 963d427..af01190 100644 --- a/doc.go +++ b/doc.go @@ -13,7 +13,6 @@ // limitations under the License. /* - Package errors provides an Error interface and several concrete types implementing this interface to manage API errors and JSON-schema validation errors. @@ -23,6 +22,5 @@ it defines. It is used throughout the various go-openapi toolkit libraries (https://github.com/go-openapi). - */ package errors diff --git a/middleware.go b/middleware.go index c26ad48..963472d 100644 --- a/middleware.go +++ b/middleware.go @@ -28,7 +28,6 @@ type APIVerificationFailed struct { MissingRegistration []string `json:"missingRegistration,omitempty"` } -// func (v *APIVerificationFailed) Error() string { buf := bytes.NewBuffer(nil)