Skip to content

Commit 25e3992

Browse files
authored
chore: Add support for go1.23 and golangci-lint v1.60.1 (#3101)
* Bump min go to 1.22, bump golangci-lint to v1.60.1, regenerate all msgp * Fix golanci-lint issues * Fix golanci-lint issues
1 parent e437633 commit 25e3992

38 files changed

+1381
-196
lines changed

.github/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Fiber v3 is currently in beta and under active development. While it offers exci
3939

4040
## ⚙️ Installation
4141

42-
Fiber requires **Go version `1.21` or higher** to run. If you need to install or upgrade Go, visit the [official Go download page](https://go.dev/dl/). To start setting up your project. Create a new directory for your project and navigate into it. Then, initialize your project with Go modules by executing the following command in your terminal:
42+
Fiber requires **Go version `1.22` or higher** to run. If you need to install or upgrade Go, visit the [official Go download page](https://go.dev/dl/). To start setting up your project. Create a new directory for your project and navigate into it. Then, initialize your project with Go modules by executing the following command in your terminal:
4343

4444
```bash
4545
go mod init github.com/your/repo
@@ -124,7 +124,7 @@ We **listen** to our users in [issues](https://github.com/gofiber/fiber/issues),
124124

125125
## ⚠️ Limitations
126126

127-
- Due to Fiber's usage of unsafe, the library may not always be compatible with the latest Go version. Fiber v3 has been tested with Go versions 1.21 and 1.22.
127+
- Due to Fiber's usage of unsafe, the library may not always be compatible with the latest Go version. Fiber v3 has been tested with Go versions 1.22 and 1.23.
128128
- Fiber is not compatible with net/http interfaces. This means you will not be able to use projects like gqlgen, go-swagger, or any others which are part of the net/http ecosystem.
129129

130130
## 👀 Examples
@@ -615,7 +615,7 @@ List of externally hosted middleware modules and maintained by the [Fiber team](
615615
| :------------------------------------------------ | :-------------------------------------------------------------------------------------------------------------------- |
616616
| [contrib](https://github.com/gofiber/contrib) | Third party middlewares |
617617
| [storage](https://github.com/gofiber/storage) | Premade storage drivers that implement the Storage interface, designed to be used with various Fiber middlewares. |
618-
| [template](https://github.com/gofiber/template) | This package contains 9 template engines that can be used with Fiber `v3` Go version 1.21 or higher is required. |
618+
| [template](https://github.com/gofiber/template) | This package contains 9 template engines that can be used with Fiber `v3` Go version 1.22 or higher is required. |
619619

620620
## 🕶️ Awesome List
621621

.github/workflows/benchmark.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
uses: actions/setup-go@v5
3232
with:
3333
# NOTE: Keep this in sync with the version from go.mod
34-
go-version: "1.21.x"
34+
go-version: "1.22.x"
3535

3636
- name: Run Benchmark
3737
run: set -o pipefail; go test ./... -benchmem -run=^$ -bench . | tee output.txt

.github/workflows/linter.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ jobs:
3030
- uses: actions/setup-go@v5
3131
with:
3232
# NOTE: Keep this in sync with the version from go.mod
33-
go-version: "1.21.x"
33+
go-version: "1.22.x"
3434
cache: false
3535

3636
- name: golangci-lint
3737
uses: golangci/golangci-lint-action@v6
3838
with:
3939
# NOTE: Keep this in sync with the version from .golangci.yml
40-
version: v1.59.1
40+
version: v1.60.1

.github/workflows/test.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
unit:
1616
strategy:
1717
matrix:
18-
go-version: [1.21.x, 1.22.x]
19-
platform: [ubuntu-latest, windows-latest, macos-latest, macos-14]
18+
go-version: [1.22.x, 1.23.x]
19+
platform: [ubuntu-latest, windows-latest, macos-latest, macos-13]
2020
runs-on: ${{ matrix.platform }}
2121
steps:
2222
- name: Fetch Repository
@@ -31,7 +31,7 @@ jobs:
3131
run: go run gotest.tools/gotestsum@latest -f testname -- ./... -race -count=1 -coverprofile=coverage.txt -covermode=atomic -shuffle=on
3232

3333
- name: Upload coverage reports to Codecov
34-
if: ${{ matrix.platform == 'ubuntu-latest' && matrix.go-version == '1.22.x' }}
34+
if: ${{ matrix.platform == 'ubuntu-latest' && matrix.go-version == '1.23.x' }}
3535
uses: codecov/[email protected]
3636
with:
3737
token: ${{ secrets.CODECOV_TOKEN }}

Makefile

+11-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ markdown:
3535
## lint: 🚨 Run lint checks
3636
.PHONY: lint
3737
lint:
38-
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1 run ./...
38+
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1 run ./...
3939

4040
## test: 🚦 Execute all tests
4141
.PHONY: test
@@ -55,4 +55,13 @@ tidy:
5555
## betteralign: 📐 Optimize alignment of fields in structs
5656
.PHONY: betteralign
5757
betteralign:
58-
go run github.com/dkorunic/betteralign/cmd/betteralign@latest -test_files -generated_files -apply ./...
58+
go run github.com/dkorunic/betteralign/cmd/betteralign@latest -test_files -generated_files -apply ./...
59+
60+
## tidy: ⚡️ Generate msgp
61+
.PHONY: msgp
62+
msgp:
63+
go run github.com/tinylib/msgp@latest -file="middleware/cache/manager.go" -o="middleware/cache/manager_msgp.go" -tests=true -unexported
64+
go run github.com/tinylib/msgp@latest -file="middleware/session/data.go" -o="middleware/session/data_msgp.go" -tests=true -unexported
65+
go run github.com/tinylib/msgp@latest -file="middleware/csrf/storage_manager.go" -o="middleware/csrf/storage_manager_msgp.go" -tests=true -unexported
66+
go run github.com/tinylib/msgp@latest -file="middleware/limiter/manager.go" -o="middleware/limiter/manager_msgp.go" -tests=true -unexported
67+
go run github.com/tinylib/msgp@latest -file="middleware/idempotency/response.go" -o="middleware/idempotency/response_msgp.go" -tests=true -unexported

client/client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ func setConfigToRequest(req *Request, config ...Config) {
674674
return
675675
}
676676

677-
if cfg.File != nil && len(cfg.File) != 0 {
677+
if len(cfg.File) != 0 {
678678
req.AddFiles(cfg.File...)
679679
return
680680
}

client/client_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ func Test_Set_Config_To_Request(t *testing.T) {
14221422
key := struct{}{}
14231423

14241424
ctx := context.Background()
1425-
ctx = context.WithValue(ctx, key, "v1")
1425+
ctx = context.WithValue(ctx, key, "v1") //nolint: staticcheck // not needed for tests
14261426

14271427
req := AcquireRequest()
14281428

client/request_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func Test_Request_Context(t *testing.T) {
8484

8585
require.Nil(t, ctx.Value(key))
8686

87-
ctx = context.WithValue(ctx, key, "string")
87+
ctx = context.WithValue(ctx, key, "string") //nolint: staticcheck // not needed for tests
8888
req.SetContext(ctx)
8989
ctx = req.Context()
9090

@@ -1603,8 +1603,8 @@ func Benchmark_SetValWithStruct(b *testing.B) {
16031603
require.Empty(b, string(p.Peek("TInt")))
16041604
require.Empty(b, string(p.Peek("TString")))
16051605
require.Empty(b, string(p.Peek("TFloat")))
1606-
require.Empty(b, len(p.PeekMulti("TSlice")))
1607-
require.Empty(b, len(p.PeekMulti("int_slice")))
1606+
require.Empty(b, p.PeekMulti("TSlice"))
1607+
require.Empty(b, p.PeekMulti("int_slice"))
16081608
})
16091609

16101610
b.Run("error type should ignore", func(b *testing.B) {

ctx_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ func Test_Ctx_UserContext(t *testing.T) {
867867
t.Parallel()
868868
testKey := struct{}{}
869869
testValue := "Test Value"
870-
ctx := context.WithValue(context.Background(), testKey, testValue)
870+
ctx := context.WithValue(context.Background(), testKey, testValue) //nolint: staticcheck // not needed for tests
871871
require.Equal(t, testValue, ctx.Value(testKey))
872872
})
873873
}
@@ -880,7 +880,7 @@ func Test_Ctx_SetUserContext(t *testing.T) {
880880

881881
testKey := struct{}{}
882882
testValue := "Test Value"
883-
ctx := context.WithValue(context.Background(), testKey, testValue)
883+
ctx := context.WithValue(context.Background(), testKey, testValue) //nolint: staticcheck // not needed for tests
884884
c.SetUserContext(ctx)
885885
require.Equal(t, testValue, c.UserContext().Value(testKey))
886886
}
@@ -900,7 +900,7 @@ func Test_Ctx_UserContext_Multiple_Requests(t *testing.T) {
900900
}
901901

902902
input := utils.CopyString(Query(c, "input", "NO_VALUE"))
903-
ctx = context.WithValue(ctx, testKey, fmt.Sprintf("%s_%s", testValue, input))
903+
ctx = context.WithValue(ctx, testKey, fmt.Sprintf("%s_%s", testValue, input)) //nolint: staticcheck // not needed for tests
904904
c.SetUserContext(ctx)
905905

906906
return c.Status(StatusOK).SendString(fmt.Sprintf("resp_%s_returned", input))

docs/intro.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ These docs are for **Fiber v3**, which was released on **March XX, 2024**.
1212

1313
### Installation
1414

15-
First of all, [download](https://go.dev/dl/) and install Go. `1.21` or higher is required.
15+
First of all, [download](https://go.dev/dl/) and install Go. `1.22` or higher is required.
1616

1717
Installation is done using the [`go get`](https://pkg.go.dev/cmd/go/#hdr-Add_dependencies_to_current_module_and_install_them) command:
1818

docs/whats_new.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Here's a quick overview of the changes in Fiber `v3`:
3838

3939
## Drop for old Go versions
4040

41-
Fiber `v3` drops support for Go versions below `1.21`. We recommend upgrading to Go `1.21` or higher to use Fiber `v3`.
41+
Fiber `v3` drops support for Go versions below `1.22`. We recommend upgrading to Go `1.22` or higher to use Fiber `v3`.
4242

4343
## 🚀 App
4444

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/gofiber/fiber/v3
22

3-
go 1.21
3+
go 1.22
44

55
require (
66
github.com/gofiber/utils/v2 v2.0.0-beta.6

helpers_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package fiber
66

77
import (
8-
"fmt"
98
"strings"
109
"testing"
1110
"time"
@@ -533,8 +532,7 @@ func Test_Utils_IsNoCache(t *testing.T) {
533532

534533
for _, c := range testCases {
535534
ok := isNoCache(c.string)
536-
require.Equal(t, c.bool, ok,
537-
fmt.Sprintf("want %t, got isNoCache(%s)=%t", c.bool, c.string, ok))
535+
require.Equal(t, c.bool, ok, "want %t, got isNoCache(%s)=%t", c.bool, c.string, ok)
538536
}
539537
}
540538

listen.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ func (app *App) startupMessage(addr string, isTLS bool, pids string, cfg ListenC
351351
}
352352

353353
fmt.Fprintf(out, "%s\n", fmt.Sprintf(figletFiberText, colors.Red+"v"+Version+colors.Reset)) //nolint:errcheck,revive // ignore error
354-
fmt.Fprintf(out, strings.Repeat("-", 50)+"\n") //nolint:errcheck,revive // ignore error
354+
fmt.Fprintf(out, strings.Repeat("-", 50)+"\n") //nolint:errcheck,revive,govet // ignore error
355355

356356
if host == "0.0.0.0" {
357357
//nolint:errcheck,revive // ignore error

middleware/cache/cache_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ func Test_Cache_MaxBytesOrder(t *testing.T) {
880880
for idx, tcase := range cases {
881881
rsp, err := app.Test(httptest.NewRequest(fiber.MethodGet, tcase[0], nil))
882882
require.NoError(t, err)
883-
require.Equal(t, tcase[1], rsp.Header.Get("X-Cache"), fmt.Sprintf("Case %v", idx))
883+
require.Equal(t, tcase[1], rsp.Header.Get("X-Cache"), "Case %v", idx)
884884
}
885885
}
886886

@@ -914,7 +914,7 @@ func Test_Cache_MaxBytesSizes(t *testing.T) {
914914
for idx, tcase := range cases {
915915
rsp, err := app.Test(httptest.NewRequest(fiber.MethodGet, tcase[0], nil))
916916
require.NoError(t, err)
917-
require.Equal(t, tcase[1], rsp.Header.Get("X-Cache"), fmt.Sprintf("Case %v", idx))
917+
require.Equal(t, tcase[1], rsp.Header.Get("X-Cache"), "Case %v", idx)
918918
}
919919
}
920920

middleware/cache/manager.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import (
88
"github.com/gofiber/fiber/v3/internal/memory"
99
)
1010

11-
// go:generate msgp
12-
// msgp -file="manager.go" -o="manager_msgp.go" -tests=false -unexported
11+
// msgp -file="manager.go" -o="manager_msgp.go" -tests=true -unexported
12+
//
13+
//go:generate msgp
1314
type item struct {
1415
headers map[string][]byte
1516
body []byte

0 commit comments

Comments
 (0)