From d5444a1746a250b269e8e963af3305756de801d0 Mon Sep 17 00:00:00 2001 From: Nathan ter Bogt Date: Fri, 17 Apr 2026 12:52:01 +1200 Subject: [PATCH 1/2] Upgrading to go 1.26. Implementing mise. --- .github/workflows/lint.yml | 17 +++++++------- .github/workflows/packages.yml | 2 +- .gitignore | 1 + .mise.toml | 43 ++++++++++++++++++++++++++++++++++ Makefile | 6 ----- go.mod | 2 +- internal/server/server.go | 11 ++++----- 7 files changed, 59 insertions(+), 23 deletions(-) create mode 100644 .mise.toml delete mode 100644 Makefile diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index afdfef3..8639944 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: Lint +name: golangci-lint on: push: @@ -14,13 +14,12 @@ jobs: name: lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' + - name: 📦 Install Mise + run: | + curl https://mise.run | sh + mise install - - name: golangci-lint - uses: golangci/golangci-lint-action@v8 - with: - version: v2.4 + - name: lint + run: mise lint diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 050570b..91491ba 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Install Go uses: actions/setup-go@v5 diff --git a/.gitignore b/.gitignore index dd5d55e..043dbe5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea dist/* vendor +bin/ diff --git a/.mise.toml b/.mise.toml new file mode 100644 index 0000000..ab19c5a --- /dev/null +++ b/.mise.toml @@ -0,0 +1,43 @@ +[tools] +go = "1.26" +"go:github.com/daixiang0/gci" = "latest" +"ubi:golangci/golangci-lint" = "2.10" +"ubi:goreleaser/goreleaser" = "2.14" + +[env] +CGO_ENABLED=0 +LGFLAGS="-extldflags '-static'" + +[tasks.vendor] +description = "Vendor resets the main module's vendor directory to include all packages needed to build the application" +run = "go mod vendor" + +[tasks.tidy] +description = "Tidy makes sure go.mod matches the source code in the module" +run = "go mod tidy" + +[tasks.build] +description = "Build the application" +run = ''' +go build -o bin/proxy-app -ldflags=${LDFLAGS} github.com/skpr/proxy-app +''' +depends = ["vendor"] + +[tasks."lint"] +description = "Linting automatically checks code for errors and style issues" +run = "golangci-lint run" + +[tasks.test] +description = "Checks to verify code correctness" +run = "go test -cover ./..." +depends = ["vendor"] + +[tasks.release] +description = "Release the command line interface" +run = "goreleaser release" +depends = ["vendor"] + +[tasks.snapshot] +description = "Create a snapshot release for local testing" +run = "goreleaser release --snapshot --clean" +depends = ["vendor"] diff --git a/Makefile b/Makefile deleted file mode 100644 index c755b26..0000000 --- a/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/make -f - -lint: - revive -set_exit_status -exclude=./vendor/... ./... - -.PHONY: * diff --git a/go.mod b/go.mod index 96fb006..e8868a4 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/skpr/proxy-app -go 1.25 +go 1.26 require ( github.com/skpr/go-config v0.0.0-20210803015120-ef4cd8061d76 diff --git a/internal/server/server.go b/internal/server/server.go index 136a723..e151ca6 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -52,23 +52,22 @@ func Run(params RunParams, config config.File) error { proxy := httputil.NewSingleHostReverseProxy(endpoint) - d := proxy.Director - // Don't recompute this for every request... basicAuthHeader := "" if params.Username != "" { basicAuthHeader = fmt.Sprintf("Basic %s", basicAuth(params.Username, params.Password)) } - proxy.Director = func(r *http.Request) { - d(r) // call default director + proxy.Rewrite = func(r *httputil.ProxyRequest) { + r.SetURL(endpoint) + r.SetXForwarded() if basicAuthHeader != "" { - r.Header.Set("Authorization", basicAuthHeader) + r.Out.Header.Set("Authorization", basicAuthHeader) } if params.TrimPathPrefix != "" { - r.URL.Path = strings.TrimPrefix(r.URL.Path, params.TrimPathPrefix) + r.Out.URL.Path = strings.TrimPrefix(r.Out.URL.Path, params.TrimPathPrefix) } } From 831d112d95435f47d40fc4c8aa2806fbe09d266a Mon Sep 17 00:00:00 2001 From: Nathan ter Bogt Date: Fri, 17 Apr 2026 12:53:40 +1200 Subject: [PATCH 2/2] Don't change workflow name --- .github/workflows/lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8639944..5aaea60 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: golangci-lint +name: Lint on: push: @@ -10,7 +10,7 @@ permissions: contents: read jobs: - golangci: + lint: name: lint runs-on: ubuntu-latest steps: