Skip to content

Commit a8e7e00

Browse files
authored
[!] bump Go to v1.26 (#1207)
* bump Go to v1.26 * remove `greenteagc` option * fix new `url.Parse()` behavior `net/url.Parse()` now rejects malformed URLs containing colons in the host subcomponent
1 parent 09dbb33 commit a8e7e00

14 files changed

Lines changed: 321 additions & 37 deletions

File tree

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Set up Golang
3030
uses: actions/setup-go@v6
3131
with:
32-
go-version: '1.25'
32+
go-version: '1.26'
3333
cache-dependency-path: 'go.sum'
3434

3535
- name: Setup Protobuf
@@ -84,7 +84,7 @@ jobs:
8484
- name: Set up Golang
8585
uses: actions/setup-go@v6
8686
with:
87-
go-version: '1.25'
87+
go-version: '1.26'
8888
cache-dependency-path: 'go.sum'
8989

9090
- name: Download webui artifact
@@ -119,7 +119,7 @@ jobs:
119119
- name: Set up Golang
120120
uses: actions/setup-go@v6
121121
with:
122-
go-version: '1.25'
122+
go-version: '1.26'
123123
cache-dependency-path: 'go.sum'
124124

125125
- name: Set up Node.js
@@ -187,7 +187,7 @@ jobs:
187187
- name: Set up Golang
188188
uses: actions/setup-go@v6
189189
with:
190-
go-version: '1.25'
190+
go-version: '1.26'
191191

192192
- name: Set up gopages
193193
run: go install github.com/johnstarich/go/[email protected]

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Set up Golang
2323
uses: actions/setup-go@v6
2424
with:
25-
go-version: '1.25'
25+
go-version: '1.26'
2626

2727
- name: Check out code into the Go module directory
2828
uses: actions/checkout@v6

.goreleaser.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ builds:
88
- main: ./cmd/pgwatch
99
env:
1010
- CGO_ENABLED=0
11-
- GOEXPERIMENT=greenteagc
1211
goos:
1312
- linux
1413
- darwin

cmd/convert_metrics/convert_metrics_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ func downloadAndExtractMetrics(t *testing.T, dest string) string {
5353

5454
var extracted string
5555
for _, f := range r.File {
56-
if strings.HasPrefix(f.Name, metricsRoot) {
57-
rel := strings.TrimPrefix(f.Name, metricsRoot)
56+
if after, ok := strings.CutPrefix(f.Name, metricsRoot); ok {
57+
rel := after
5858
if rel == "" {
5959
extracted = filepath.Join(dest, "metrics")
6060
_ = os.MkdirAll(extracted, 0755)

cmd/pgwatch/main_integration_test.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"os"
66
"path/filepath"
7+
"strings"
78
"testing"
89
"time"
910

@@ -144,18 +145,18 @@ metrics:
144145
specialSourcesYaml := filepath.Join(tempDir, "special_sources.yaml")
145146

146147
// Build YAML with all special source names
147-
yamlContent := ""
148+
var yamlContent strings.Builder
148149
for _, name := range specialNames {
149-
yamlContent += `
150+
yamlContent.WriteString(`
150151
- name: ` + name + `
151152
conn_str: ` + connStr + `
152153
kind: postgres
153154
is_enabled: true
154155
custom_metrics:
155156
test_metric: 60
156-
`
157+
`)
157158
}
158-
require.NoError(t, os.WriteFile(specialSourcesYaml, []byte(yamlContent), 0644))
159+
require.NoError(t, os.WriteFile(specialSourcesYaml, []byte(yamlContent.String()), 0644))
159160

160161
os.Args = []string{
161162
"pgwatch",
@@ -262,7 +263,7 @@ presets:
262263

263264
go main()
264265

265-
// Below tests are expected to run sequentially and depend on
266+
// Below tests are expected to run sequentially and depend on
266267
// data generated by each other
267268

268269
t.Run("Ensure tag changes are applied", func(t *testing.T) {
@@ -323,7 +324,7 @@ presets:
323324
require.GreaterOrEqual(t, len(epochNsBefore), 2, "we need at least 2 measurements")
324325

325326
// Calculate interval before change
326-
intervalBefore := float64(epochNsBefore[0] - epochNsBefore[1]) / 1e9
327+
intervalBefore := float64(epochNsBefore[0]-epochNsBefore[1]) / 1e9
327328
assert.InDelta(t, 1.0, intervalBefore, 0.5, "interval should be approximately 1 second")
328329

329330
// Change interval to 2 seconds
@@ -355,7 +356,7 @@ presets:
355356
require.GreaterOrEqual(t, len(epochNsAfter), 2, "we need at least 2 measurements after interval change")
356357

357358
// Calculate interval after change
358-
intervalAfter := float64(epochNsAfter[0] - epochNsAfter[1]) / 1e9
359+
intervalAfter := float64(epochNsAfter[0]-epochNsAfter[1]) / 1e9
359360
assert.InDelta(t, 2.0, intervalAfter, 0.5, "new interval should be approximately 2 seconds")
360361
assert.Greater(t, intervalAfter, intervalBefore, "new interval should be greater than old interval")
361362
})
@@ -387,7 +388,7 @@ presets:
387388
`SELECT count(*) FROM public.test_metric WHERE dbname = 'test_source'`).Scan(&countAfter)
388389
require.NoError(t, err)
389390

390-
assert.LessOrEqual(t, countAfter - countBefore, 2)
391+
assert.LessOrEqual(t, countAfter-countBefore, 2)
391392
})
392393

393394
t.Run("Ensure preset intervals updates are applied - issue #1091", func(t *testing.T) {
@@ -420,7 +421,7 @@ presets:
420421
require.GreaterOrEqual(t, len(epochNsBefore), 2, "should have at least 2 measurements")
421422

422423
// Calculate interval before change
423-
intervalBefore := float64(epochNsBefore[0] - epochNsBefore[1]) / 1e9
424+
intervalBefore := float64(epochNsBefore[0]-epochNsBefore[1]) / 1e9
424425
assert.InDelta(t, 1.0, intervalBefore, 0.5, "interval should be approximately 1 second")
425426

426427
require.NoError(t, os.WriteFile(sourcesYaml, []byte(`
@@ -463,7 +464,7 @@ presets:
463464
require.GreaterOrEqual(t, len(epochNsAfter), 2, "should have at least 2 measurements")
464465

465466
// Calculate interval after change
466-
intervalAfter := float64(epochNsAfter[0] - epochNsAfter[1]) / 1e9
467+
intervalAfter := float64(epochNsAfter[0]-epochNsAfter[1]) / 1e9
467468
assert.InDelta(t, 2.0, intervalAfter, 0.5, "interval should be approximately 2 seconds")
468469
})
469470

docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ RUN yarn build
2323
# ----------------------------------------------------------------
2424
# 3. Go Dependencies and Tools (cached separately)
2525
# ----------------------------------------------------------------
26-
FROM golang:1.25 AS go-deps
26+
FROM golang:1.26 AS go-deps
2727
# Install protoc and required tools for protobuf generation
2828
RUN apt-get update && apt-get install -y protobuf-compiler && rm -rf /var/lib/apt/lists/*
2929
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
@@ -50,7 +50,7 @@ COPY --from=webui-builder /webserver/build ./internal/webserver/build
5050

5151
# Generate protobuf and build the application
5252
RUN go generate ./api/pb/ && \
53-
CGO_ENABLED=0 GOEXPERIMENT=greenteagc go build -ldflags "\
53+
CGO_ENABLED=0 go build -ldflags "\
5454
-X 'main.commit=${GIT_HASH}' \
5555
-X 'main.date=${GIT_TIME}' \
5656
-X 'main.version=${VERSION}'" ./cmd/pgwatch

docker/demo/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ RUN yarn build
2323
# ----------------------------------------------------------------
2424
# 3. Go Dependencies and Tools (cached separately)
2525
# ----------------------------------------------------------------
26-
FROM golang:1.25 AS go-deps
26+
FROM golang:1.26 AS go-deps
2727
# Install protoc and required tools for protobuf generation
2828
RUN apt-get update && apt-get install -y protobuf-compiler && rm -rf /var/lib/apt/lists/*
2929
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
@@ -50,7 +50,7 @@ COPY --from=webui-builder /webserver/build ./internal/webserver/build
5050

5151
# Generate protobuf and build the application
5252
RUN go generate ./api/pb/ && \
53-
CGO_ENABLED=0 GOEXPERIMENT=greenteagc go build -ldflags "\
53+
CGO_ENABLED=0 go build -ldflags "\
5454
-X 'main.commit=${GIT_HASH}' \
5555
-X 'main.date=${GIT_TIME}' \
5656
-X 'main.version=${VERSION}'" ./cmd/pgwatch

go.mod

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

3-
go 1.25.0
3+
go 1.26.0
44

55
require (
66
github.com/cybertec-postgresql/pgx-migrator v1.3.0

internal/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ set -x
66
GIT_HASH=$(git show -s --format=%H HEAD)
77
GIT_TIME=$(git show -s --format=%cI HEAD)
88
VERSION=$(git rev-parse --abbrev-ref HEAD)
9-
GOEXPERIMENT=greenteagc go build -ldflags "-X 'main.commit=$GIT_HASH' -X 'main.date=$GIT_TIME' -X 'main.version=$VERSION'"
9+
go build -ldflags "-X 'main.commit=$GIT_HASH' -X 'main.date=$GIT_TIME' -X 'main.version=$VERSION'"

internal/db/conn.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ import (
1515
)
1616

1717
type Querier interface {
18-
Query(ctx context.Context, query string, args ...interface{}) (pgx.Rows, error)
18+
Query(ctx context.Context, query string, args ...any) (pgx.Rows, error)
1919
}
2020

2121
// PgxIface is common interface for every pgx class
2222
type PgxIface interface {
2323
Begin(ctx context.Context) (pgx.Tx, error)
24-
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
25-
QueryRow(context.Context, string, ...interface{}) pgx.Row
26-
Query(ctx context.Context, query string, args ...interface{}) (pgx.Rows, error)
24+
Exec(context.Context, string, ...any) (pgconn.CommandTag, error)
25+
QueryRow(context.Context, string, ...any) pgx.Row
26+
Query(ctx context.Context, query string, args ...any) (pgx.Rows, error)
2727
CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)
2828
}
2929

0 commit comments

Comments
 (0)