From bf1c0c5f19fbe3027283834357e5165618c8d2b6 Mon Sep 17 00:00:00 2001 From: Johannes Eiglsperger Date: Fri, 9 Feb 2024 10:08:53 +0100 Subject: [PATCH 1/2] Support Go 1.22, drop Go 1.20 --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f10e714..7bcaca6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - name: Check out code into the Go module directory uses: actions/checkout@v4 - name: golangci-lint @@ -31,7 +31,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - goVer: ["1.20", "1.21"] + goVer: ["1.21", "1.22"] steps: - name: Set up Go ${{ matrix.goVer }} uses: actions/setup-go@v5 From 977a984edabe7facff7327ba855974b00645d583 Mon Sep 17 00:00:00 2001 From: Johannes Eiglsperger Date: Fri, 9 Feb 2024 10:09:56 +0100 Subject: [PATCH 2/2] Split integration test and example --- cachecontrol_example_test.go | 33 +++++++++++++++++++ ...est.go => cachecontrol_integration_test.go | 25 -------------- 2 files changed, 33 insertions(+), 25 deletions(-) create mode 100644 cachecontrol_example_test.go rename cachecontrol_test.go => cachecontrol_integration_test.go (81%) diff --git a/cachecontrol_example_test.go b/cachecontrol_example_test.go new file mode 100644 index 0000000..8238bda --- /dev/null +++ b/cachecontrol_example_test.go @@ -0,0 +1,33 @@ +package cachecontrol_test + +import ( + "github.com/gin-gonic/gin" + cachecontrol "go.eigsys.de/gin-cachecontrol/v2" + "net/http" + "time" +) + +func ExampleNew() { + router := gin.Default() + + router.Use(cachecontrol.New(cachecontrol.Config{ + MustRevalidate: true, + NoCache: false, + NoStore: false, + NoTransform: false, + Public: true, + Private: false, + ProxyRevalidate: true, + MaxAge: cachecontrol.Duration(30 * time.Minute), + SMaxAge: nil, + Immutable: false, + StaleWhileRevalidate: cachecontrol.Duration(2 * time.Hour), + StaleIfError: cachecontrol.Duration(2 * time.Hour), + })) + + router.GET("/", func(ginCtx *gin.Context) { + ginCtx.String(http.StatusOK, "Hello, Gopher!") + }) + + _ = router.Run() +} diff --git a/cachecontrol_test.go b/cachecontrol_integration_test.go similarity index 81% rename from cachecontrol_test.go rename to cachecontrol_integration_test.go index a1ea467..f480da0 100644 --- a/cachecontrol_test.go +++ b/cachecontrol_integration_test.go @@ -107,28 +107,3 @@ func TestNew(t *testing.T) { }) } } - -func ExampleNew() { - router := gin.Default() - - router.Use(cachecontrol.New(cachecontrol.Config{ - MustRevalidate: true, - NoCache: false, - NoStore: false, - NoTransform: false, - Public: true, - Private: false, - ProxyRevalidate: true, - MaxAge: cachecontrol.Duration(30 * time.Minute), - SMaxAge: nil, - Immutable: false, - StaleWhileRevalidate: cachecontrol.Duration(2 * time.Hour), - StaleIfError: cachecontrol.Duration(2 * time.Hour), - })) - - router.GET("/", func(ginCtx *gin.Context) { - ginCtx.String(http.StatusOK, "Hello, Gopher!") - }) - - _ = router.Run() -}