Skip to content

Commit 5394d09

Browse files
authored
chore: Upgrade to go 1.26 (#1655)
1 parent f48ecc0 commit 5394d09

File tree

153 files changed

+566
-804
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+566
-804
lines changed

.github/workflows/ci.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ on:
2727
- ".github/workflows/ci.yaml"
2828

2929
env:
30-
GO_VERSION: "1.25"
30+
GO_VERSION: "1.26"
3131

3232
jobs:
3333
# Spell check
@@ -58,12 +58,21 @@ jobs:
5858
run: |
5959
go fmt ./...
6060
# Fail if formatting changed any files
61-
git diff --exit-code || (echo "Go files are not formatted. Please run 'go fmt ./...'" && exit 1)
61+
git diff --exit-code || (echo "Go files are not formatted. Please run 'make fmt'" && exit 1)
62+
63+
- name: Check modernize (go fix)
64+
run: |
65+
diff=$(go fix -diff ./... 2>&1) || true
66+
if [ -n "$diff" ]; then
67+
echo "Go files need modernization. Please run 'make fmt'"
68+
echo "$diff"
69+
exit 1
70+
fi
6271
6372
- name: Run golangci-lint
6473
uses: golangci/golangci-lint-action@v9
6574
with:
66-
version: v2.5.0
75+
version: v2.9.0
6776
args: --timeout=10m
6877

6978
# Test Go code on multiple platforms

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN rm -rf node_modules; \
1313
pnpm build
1414

1515
# Stage 2: Go Builder
16-
FROM --platform=$TARGETPLATFORM golang:1.25-alpine AS go-builder
16+
FROM --platform=$TARGETPLATFORM golang:1.26-alpine AS go-builder
1717
ARG LDFLAGS
1818
ARG TARGETOS
1919
ARG TARGETARCH

Dockerfile.alpine

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN rm -rf node_modules; \
1313
pnpm build
1414

1515
# Stage 2: Go Builder
16-
FROM --platform=$TARGETPLATFORM golang:1.25-alpine AS go-builder
16+
FROM --platform=$TARGETPLATFORM golang:1.26-alpine AS go-builder
1717
ARG LDFLAGS
1818
ARG TARGETOS
1919
ARG TARGETARCH

Dockerfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN rm -rf node_modules; \
1313
pnpm build
1414

1515
# Stage 2: Go Builder
16-
FROM --platform=$TARGETPLATFORM golang:1.25-alpine AS go-builder
16+
FROM --platform=$TARGETPLATFORM golang:1.26-alpine AS go-builder
1717
ARG LDFLAGS
1818
ARG TARGETOS
1919
ARG TARGETARCH

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,30 @@ clean-ui:
353353
rm -rf node_modules; \
354354
rm -rf .cache;
355355

356+
# fmt auto-fixes all code style issues (go fix + go fmt + linter --fix).
357+
# AI agents and developers should run this before committing.
358+
.PHONY: fmt
359+
fmt:
360+
@echo "${COLOR_GREEN}Running go fix...${COLOR_RESET}"
361+
@go fix ./...
362+
@echo "${COLOR_GREEN}Running go fmt...${COLOR_RESET}"
363+
@go fmt ./...
364+
@echo "${COLOR_GREEN}Running linter with --fix...${COLOR_RESET}"
365+
@GOBIN=${LOCAL_BIN_DIR} go install $(PKG_golangci_lint)
366+
@${LOCAL_BIN_DIR}/golangci-lint run --fix ./...
367+
368+
# check verifies code style without modifying files (for CI).
369+
.PHONY: check
370+
check:
371+
@echo "${COLOR_GREEN}Checking go fix...${COLOR_RESET}"
372+
@diff=$$(go fix -diff ./... 2>&1); if [ -n "$$diff" ]; then echo "$$diff"; echo "${COLOR_RED}Run 'make fmt'${COLOR_RESET}"; exit 1; fi
373+
@echo "${COLOR_GREEN}Checking go fmt...${COLOR_RESET}"
374+
@go fmt ./...
375+
@git diff --exit-code || (echo "${COLOR_RED}Run 'make fmt'${COLOR_RESET}" && exit 1)
376+
@echo "${COLOR_GREEN}Running linter...${COLOR_RESET}"
377+
@GOBIN=${LOCAL_BIN_DIR} go install $(PKG_golangci_lint)
378+
@${LOCAL_BIN_DIR}/golangci-lint run --timeout=10m ./...
379+
356380
# golangci-lint run linting tool.
357381
.PHONY: golangci-lint
358382
golangci-lint:

deploy/docker/Dockerfile.alpine

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN rm -rf node_modules; \
1313
pnpm build
1414

1515
# Stage 2: Go Builder
16-
FROM --platform=$TARGETPLATFORM golang:1.25-alpine AS go-builder
16+
FROM --platform=$TARGETPLATFORM golang:1.26-alpine AS go-builder
1717
ARG LDFLAGS
1818
ARG TARGETOS
1919
ARG TARGETARCH

deploy/docker/Dockerfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN rm -rf node_modules; \
1313
pnpm build
1414

1515
# Stage 2: Go Builder
16-
FROM --platform=$TARGETPLATFORM golang:1.25-alpine AS go-builder
16+
FROM --platform=$TARGETPLATFORM golang:1.26-alpine AS go-builder
1717
ARG LDFLAGS
1818
ARG TARGETOS
1919
ARG TARGETARCH

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/dagu-org/dagu
22

3-
go 1.25.5
3+
go 1.26
44

55
require (
66
dario.cat/mergo v1.0.2

internal/agent/api.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ func (a *API) handleGetSession(w http.ResponseWriter, r *http.Request) {
453453
if mgr, ok := a.getActiveSession(id, userID); ok {
454454
a.respondJSON(w, http.StatusOK, StreamResponse{
455455
Messages: mgr.GetMessages(),
456-
Session: ptrTo(mgr.GetSession()),
456+
Session: new(mgr.GetSession()),
457457
SessionState: &SessionState{
458458
SessionID: id,
459459
Working: mgr.IsWorking(),
@@ -806,8 +806,3 @@ func (a *API) cleanupIdleSessions() {
806806
a.logger.Debug("Cleaned up idle session", "session_id", id)
807807
}
808808
}
809-
810-
// ptrTo returns a pointer to the given value.
811-
func ptrTo[T any](v T) *T {
812-
return &v
813-
}

internal/agent/patch_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"os"
77
"path/filepath"
8+
"strings"
89
"testing"
910

1011
"github.com/dagu-org/dagu/internal/core"
@@ -24,11 +25,12 @@ func TestMain(m *testing.M) {
2425
}
2526

2627
func patchInput(path, operation string, extra ...string) json.RawMessage {
27-
base := fmt.Sprintf(`{"path": %q, "operation": %q`, path, operation)
28+
var base strings.Builder
29+
base.WriteString(fmt.Sprintf(`{"path": %q, "operation": %q`, path, operation))
2830
for i := 0; i < len(extra)-1; i += 2 {
29-
base += fmt.Sprintf(`, %q: %q`, extra[i], extra[i+1])
31+
base.WriteString(fmt.Sprintf(`, %q: %q`, extra[i], extra[i+1]))
3032
}
31-
return json.RawMessage(base + "}")
33+
return json.RawMessage(base.String() + "}")
3234
}
3335

3436
func TestPatchTool_Create(t *testing.T) {

0 commit comments

Comments
 (0)