Skip to content

Commit 12384ea

Browse files
authored
Bump GitHub workflows and Go versions (#438)
1 parent 0951d18 commit 12384ea

File tree

7 files changed

+20
-18
lines changed

7 files changed

+20
-18
lines changed

.github/workflows/build.yml

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

.github/workflows/lint.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
- name: Setup Go
1515
uses: actions/setup-go@v5
1616
with:
17-
go-version: "1.23"
17+
go-version: "1.24"
1818
check-latest: true
1919
- name: golangci-lint
20-
uses: golangci/golangci-lint-action@v6
20+
uses: golangci/golangci-lint-action@v7
2121
with:
2222
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
2323
version: latest

cmd/jwt/main.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ func loadData(p string) ([]byte, error) {
9191
return nil, err
9292
}
9393
rdr = f
94-
defer f.Close()
94+
if err := f.Close(); err != nil {
95+
return nil, err
96+
}
9597
}
9698
return io.ReadAll(rdr)
9799
}

example_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func ExampleParseWithClaims_customClaimsType() {
9090
if err != nil {
9191
log.Fatal(err)
9292
} else if claims, ok := token.Claims.(*MyCustomClaims); ok {
93-
fmt.Println(claims.Foo, claims.RegisteredClaims.Issuer)
93+
fmt.Println(claims.Foo, claims.Issuer)
9494
} else {
9595
log.Fatal("unknown claims type, cannot proceed")
9696
}
@@ -114,7 +114,7 @@ func ExampleParseWithClaims_validationOptions() {
114114
if err != nil {
115115
log.Fatal(err)
116116
} else if claims, ok := token.Claims.(*MyCustomClaims); ok {
117-
fmt.Println(claims.Foo, claims.RegisteredClaims.Issuer)
117+
fmt.Println(claims.Foo, claims.Issuer)
118118
} else {
119119
log.Fatal("unknown claims type, cannot proceed")
120120
}
@@ -153,7 +153,7 @@ func ExampleParseWithClaims_customValidation() {
153153
if err != nil {
154154
log.Fatal(err)
155155
} else if claims, ok := token.Claims.(*MyCustomClaims); ok {
156-
fmt.Println(claims.Foo, claims.RegisteredClaims.Issuer)
156+
fmt.Println(claims.Foo, claims.Issuer)
157157
} else {
158158
log.Fatal("unknown claims type, cannot proceed")
159159
}

http_example_test.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func Example_getTokenViaHTTP() {
9292
// Read the token out of the response body
9393
buf, err := io.ReadAll(res.Body)
9494
fatal(err)
95-
res.Body.Close()
95+
_ = res.Body.Close()
9696
tokenString := strings.TrimSpace(string(buf))
9797

9898
// Parse the token
@@ -104,7 +104,7 @@ func Example_getTokenViaHTTP() {
104104
fatal(err)
105105

106106
claims := token.Claims.(*CustomClaimsExample)
107-
fmt.Println(claims.CustomerInfo.Name)
107+
fmt.Println(claims.Name)
108108

109109
// Output: test
110110
}
@@ -126,7 +126,7 @@ func Example_useTokenViaHTTP() {
126126
// Read the response body
127127
buf, err := io.ReadAll(res.Body)
128128
fatal(err)
129-
res.Body.Close()
129+
_ = res.Body.Close()
130130
fmt.Printf("%s", buf)
131131

132132
// Output: Welcome, foo
@@ -156,7 +156,7 @@ func authHandler(w http.ResponseWriter, r *http.Request) {
156156
// make sure its post
157157
if r.Method != "POST" {
158158
w.WriteHeader(http.StatusBadRequest)
159-
fmt.Fprintln(w, "No POST", r.Method)
159+
_, _ = fmt.Fprintln(w, "No POST", r.Method)
160160
return
161161
}
162162

@@ -168,21 +168,21 @@ func authHandler(w http.ResponseWriter, r *http.Request) {
168168
// check values
169169
if user != "test" || pass != "known" {
170170
w.WriteHeader(http.StatusForbidden)
171-
fmt.Fprintln(w, "Wrong info")
171+
_, _ = fmt.Fprintln(w, "Wrong info")
172172
return
173173
}
174174

175175
tokenString, err := createToken(user)
176176
if err != nil {
177177
w.WriteHeader(http.StatusInternalServerError)
178-
fmt.Fprintln(w, "Sorry, error while Signing Token!")
178+
_, _ = fmt.Fprintln(w, "Sorry, error while Signing Token!")
179179
log.Printf("Token Signing error: %v\n", err)
180180
return
181181
}
182182

183183
w.Header().Set("Content-Type", "application/jwt")
184184
w.WriteHeader(http.StatusOK)
185-
fmt.Fprintln(w, tokenString)
185+
_, _ = fmt.Fprintln(w, tokenString)
186186
}
187187

188188
// only accessible with a valid token
@@ -197,10 +197,10 @@ func restrictedHandler(w http.ResponseWriter, r *http.Request) {
197197
// If the token is missing or invalid, return error
198198
if err != nil {
199199
w.WriteHeader(http.StatusUnauthorized)
200-
fmt.Fprintln(w, "Invalid token:", err)
200+
_, _ = fmt.Fprintln(w, "Invalid token:", err)
201201
return
202202
}
203203

204204
// Token is valid
205-
fmt.Fprintln(w, "Welcome,", token.Claims.(*CustomClaimsExample).Name)
205+
_, _ = fmt.Fprintln(w, "Welcome,", token.Claims.(*CustomClaimsExample).Name)
206206
}

parser_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ func TestSetPadding(t *testing.T) {
744744
// Parse the token
745745
var token *jwt.Token
746746
var err error
747-
var opts []jwt.ParserOption = []jwt.ParserOption{jwt.WithoutClaimsValidation()}
747+
var opts = []jwt.ParserOption{jwt.WithoutClaimsValidation()}
748748

749749
if data.paddedDecode {
750750
opts = append(opts, jwt.WithPaddingAllowed())

validator.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func NewValidator(opts ...ParserOption) *Validator {
8888
func (v *Validator) Validate(claims Claims) error {
8989
var (
9090
now time.Time
91-
errs []error = make([]error, 0, 6)
91+
errs = make([]error, 0, 6)
9292
err error
9393
)
9494

0 commit comments

Comments
 (0)