Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: ["1.22", "1.23", "1.24"]
go: ["1.21", "1.22", "1.23", "1.24"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
40 changes: 40 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package jwt

import (
"errors"
"fmt"
"strings"
)

Expand Down Expand Up @@ -47,3 +48,42 @@ func joinErrors(errs ...error) error {
errs: errs,
}
}

// Unwrap implements the multiple error unwrapping for this error type, which is
// possible in Go 1.20.
func (je joinedError) Unwrap() []error {
return je.errs
}

// newError creates a new error message with a detailed error message. The
// message will be prefixed with the contents of the supplied error type.
// Additionally, more errors, that provide more context can be supplied which
// will be appended to the message. This makes use of Go 1.20's possibility to
// include more than one %w formatting directive in [fmt.Errorf].
//
// For example,
//
// newError("no keyfunc was provided", ErrTokenUnverifiable)
//
// will produce the error string
//
// "token is unverifiable: no keyfunc was provided"
func newError(message string, err error, more ...error) error {
var format string
var args []any
if message != "" {
format = "%w: %s"
args = []any{err, message}
} else {
format = "%w"
args = []any{err}
}

for _, e := range more {
format += ": %w"
args = append(args, e)
}

err = fmt.Errorf(format, args...)
return err
}
47 changes: 0 additions & 47 deletions errors_go1_20.go

This file was deleted.

78 changes: 0 additions & 78 deletions errors_go_other.go

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/golang-jwt/jwt/v5

go 1.18
go 1.21
3 changes: 0 additions & 3 deletions rsa_pss.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build go1.4
// +build go1.4

package jwt

import (
Expand Down
3 changes: 0 additions & 3 deletions rsa_pss_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build go1.4
// +build go1.4

package jwt_test

import (
Expand Down