Skip to content

Commit e9547a1

Browse files
authored
Bump Go version to indicate correct minimum requirement (#452)
* Bump Go version to indicate correct minimum requirement The minimum requirement that we have was silently bumped to 1.21 in #441 because of the `slices` package. It seems that we did not update the `go.mod` when we updated our CI range, because CI did not fail because it was not testing older versions. We probably should just update the `go.mod` when we update the CI target in the future? Although we could theoretically stay at 1.21 in terms of the code base. * Removed outdated build tags * Remove more build tags * Removed code for Go < 1.20
1 parent 3839817 commit e9547a1

File tree

7 files changed

+42
-133
lines changed

7 files changed

+42
-133
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
go: ["1.22", "1.23", "1.24"]
16+
go: ["1.21", "1.22", "1.23", "1.24"]
1717
steps:
1818
- name: Checkout
1919
uses: actions/checkout@v4

errors.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package jwt
22

33
import (
44
"errors"
5+
"fmt"
56
"strings"
67
)
78

@@ -47,3 +48,42 @@ func joinErrors(errs ...error) error {
4748
errs: errs,
4849
}
4950
}
51+
52+
// Unwrap implements the multiple error unwrapping for this error type, which is
53+
// possible in Go 1.20.
54+
func (je joinedError) Unwrap() []error {
55+
return je.errs
56+
}
57+
58+
// newError creates a new error message with a detailed error message. The
59+
// message will be prefixed with the contents of the supplied error type.
60+
// Additionally, more errors, that provide more context can be supplied which
61+
// will be appended to the message. This makes use of Go 1.20's possibility to
62+
// include more than one %w formatting directive in [fmt.Errorf].
63+
//
64+
// For example,
65+
//
66+
// newError("no keyfunc was provided", ErrTokenUnverifiable)
67+
//
68+
// will produce the error string
69+
//
70+
// "token is unverifiable: no keyfunc was provided"
71+
func newError(message string, err error, more ...error) error {
72+
var format string
73+
var args []any
74+
if message != "" {
75+
format = "%w: %s"
76+
args = []any{err, message}
77+
} else {
78+
format = "%w"
79+
args = []any{err}
80+
}
81+
82+
for _, e := range more {
83+
format += ": %w"
84+
args = append(args, e)
85+
}
86+
87+
err = fmt.Errorf(format, args...)
88+
return err
89+
}

errors_go1_20.go

Lines changed: 0 additions & 47 deletions
This file was deleted.

errors_go_other.go

Lines changed: 0 additions & 78 deletions
This file was deleted.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/golang-jwt/jwt/v5
22

3-
go 1.18
3+
go 1.21

rsa_pss.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build go1.4
2-
// +build go1.4
3-
41
package jwt
52

63
import (

rsa_pss_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build go1.4
2-
// +build go1.4
3-
41
package jwt_test
52

63
import (

0 commit comments

Comments
 (0)