Skip to content

Commit

Permalink
Bump min go to 1.22, bump golangci-lint to v1.60.1, regenerate all msgp
Browse files Browse the repository at this point in the history
  • Loading branch information
gaby committed Aug 14, 2024
1 parent e437633 commit 854b918
Show file tree
Hide file tree
Showing 34 changed files with 1,365 additions and 180 deletions.
6 changes: 3 additions & 3 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Fiber v3 is currently in beta and under active development. While it offers exci

## ⚙️ Installation

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:
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:

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

## ⚠️ Limitations

- 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.
- 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.
- 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.

## 👀 Examples
Expand Down Expand Up @@ -615,7 +615,7 @@ List of externally hosted middleware modules and maintained by the [Fiber team](
| :------------------------------------------------ | :-------------------------------------------------------------------------------------------------------------------- |
| [contrib](https://github.com/gofiber/contrib) | Third party middlewares |
| [storage](https://github.com/gofiber/storage) | Premade storage drivers that implement the Storage interface, designed to be used with various Fiber middlewares. |
| [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. |
| [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. |

## 🕶️ Awesome List

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: actions/setup-go@v5
with:
# NOTE: Keep this in sync with the version from go.mod
go-version: "1.21.x"
go-version: "1.22.x"

- name: Run Benchmark
run: set -o pipefail; go test ./... -benchmem -run=^$ -bench . | tee output.txt
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ jobs:
- uses: actions/setup-go@v5
with:
# NOTE: Keep this in sync with the version from go.mod
go-version: "1.21.x"
go-version: "1.22.x"
cache: false

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
# NOTE: Keep this in sync with the version from .golangci.yml
version: v1.59.1
version: v1.60.1
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
unit:
strategy:
matrix:
go-version: [1.21.x, 1.22.x]
go-version: [1.22.x, 1.23.x]
platform: [ubuntu-latest, windows-latest, macos-latest, macos-14]
runs-on: ${{ matrix.platform }}
steps:
Expand All @@ -31,7 +31,7 @@ jobs:
run: go run gotest.tools/gotestsum@latest -f testname -- ./... -race -count=1 -coverprofile=coverage.txt -covermode=atomic -shuffle=on

- name: Upload coverage reports to Codecov
if: ${{ matrix.platform == 'ubuntu-latest' && matrix.go-version == '1.22.x' }}
if: ${{ matrix.platform == 'ubuntu-latest' && matrix.go-version == '1.23.x' }}
uses: codecov/codecov-action@v4.5.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ markdown:
## lint: 🚨 Run lint checks
.PHONY: lint
lint:
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1 run ./...
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1 run ./...

## test: 🚦 Execute all tests
.PHONY: test
Expand All @@ -55,4 +55,13 @@ tidy:
## betteralign: 📐 Optimize alignment of fields in structs
.PHONY: betteralign
betteralign:
go run github.com/dkorunic/betteralign/cmd/betteralign@latest -test_files -generated_files -apply ./...
go run github.com/dkorunic/betteralign/cmd/betteralign@latest -test_files -generated_files -apply ./...

## tidy: ⚡️ Generate msgp
.PHONY: msgp
msgp:
go run github.com/tinylib/msgp@latest -file="middleware/cache/manager.go" -o="middleware/cache/manager_msgp.go" -tests=true -unexported
go run github.com/tinylib/msgp@latest -file="middleware/session/data.go" -o="middleware/session/data_msgp.go" -tests=true -unexported
go run github.com/tinylib/msgp@latest -file="middleware/csrf/storage_manager.go" -o="middleware/csrf/storage_manager_msgp.go" -tests=true -unexported
go run github.com/tinylib/msgp@latest -file="middleware/limiter/manager.go" -o="middleware/limiter/manager_msgp.go" -tests=true -unexported
go run github.com/tinylib/msgp@latest -file="middleware/idempotency/response.go" -o="middleware/idempotency/response_msgp.go" -tests=true -unexported
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ func setConfigToRequest(req *Request, config ...Config) {
return
}

if cfg.File != nil && len(cfg.File) != 0 {
if len(cfg.File) != 0 {
req.AddFiles(cfg.File...)
return
}
Expand Down
2 changes: 1 addition & 1 deletion client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ func Test_Set_Config_To_Request(t *testing.T) {
key := struct{}{}

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

req := AcquireRequest()

Expand Down
6 changes: 3 additions & 3 deletions client/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func Test_Request_Context(t *testing.T) {

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

ctx = context.WithValue(ctx, key, "string")
ctx = context.WithValue(ctx, key, "string") //nolint: staticcheck // not needed for tests
req.SetContext(ctx)
ctx = req.Context()

Expand Down Expand Up @@ -1603,8 +1603,8 @@ func Benchmark_SetValWithStruct(b *testing.B) {
require.Empty(b, string(p.Peek("TInt")))
require.Empty(b, string(p.Peek("TString")))
require.Empty(b, string(p.Peek("TFloat")))
require.Empty(b, len(p.PeekMulti("TSlice")))
require.Empty(b, len(p.PeekMulti("int_slice")))
require.Empty(b, p.PeekMulti("TSlice"))
require.Empty(b, p.PeekMulti("int_slice"))
})

b.Run("error type should ignore", func(b *testing.B) {
Expand Down
6 changes: 3 additions & 3 deletions ctx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ func Test_Ctx_UserContext(t *testing.T) {
t.Parallel()
testKey := struct{}{}
testValue := "Test Value"
ctx := context.WithValue(context.Background(), testKey, testValue)
ctx := context.WithValue(context.Background(), testKey, testValue) //nolint: staticcheck // not needed for tests
require.Equal(t, testValue, ctx.Value(testKey))
})
}
Expand All @@ -880,7 +880,7 @@ func Test_Ctx_SetUserContext(t *testing.T) {

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

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

return c.Status(StatusOK).SendString(fmt.Sprintf("resp_%s_returned", input))
Expand Down
2 changes: 1 addition & 1 deletion docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ These docs are for **Fiber v3**, which was released on **March XX, 2024**.

### Installation

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

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

Expand Down
2 changes: 1 addition & 1 deletion docs/whats_new.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Here's a quick overview of the changes in Fiber `v3`:

## Drop for old Go versions

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

## 🚀 App

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/gofiber/fiber/v3

go 1.21
go 1.22

require (
github.com/gofiber/utils/v2 v2.0.0-beta.6
Expand Down
4 changes: 1 addition & 3 deletions helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package fiber

import (
"fmt"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -533,8 +532,7 @@ func Test_Utils_IsNoCache(t *testing.T) {

for _, c := range testCases {
ok := isNoCache(c.string)
require.Equal(t, c.bool, ok,
fmt.Sprintf("want %t, got isNoCache(%s)=%t", c.bool, c.string, ok))
require.Equal(t, c.bool, ok, "want %t, got isNoCache(%s)=%t", c.bool, c.string, ok)
}
}

Expand Down
2 changes: 1 addition & 1 deletion listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func (app *App) startupMessage(addr string, isTLS bool, pids string, cfg ListenC
}

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

if host == "0.0.0.0" {
//nolint:errcheck,revive // ignore error
Expand Down
4 changes: 2 additions & 2 deletions middleware/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ func Test_Cache_MaxBytesOrder(t *testing.T) {
for idx, tcase := range cases {
rsp, err := app.Test(httptest.NewRequest(fiber.MethodGet, tcase[0], nil))
require.NoError(t, err)
require.Equal(t, tcase[1], rsp.Header.Get("X-Cache"), fmt.Sprintf("Case %v", idx))
require.Equal(t, tcase[1], rsp.Header.Get("X-Cache"), "Case %v", idx)
}
}

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

Expand Down
5 changes: 3 additions & 2 deletions middleware/cache/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (
"github.com/gofiber/fiber/v3/internal/memory"
)

// go:generate msgp
// msgp -file="manager.go" -o="manager_msgp.go" -tests=false -unexported
// msgp -file="manager.go" -o="manager_msgp.go" -tests=true -unexported
//
//go:generate msgp
type item struct {
headers map[string][]byte
body []byte
Expand Down
Loading

0 comments on commit 854b918

Please sign in to comment.