Skip to content

Commit 489439d

Browse files
authored
Upgrade to go 1.26 (#601)
## Summary Upgrades the Go toolchain from 1.24.2 to 1.26.0, bumps the CI PostGIS image from EOL PG 12 to PG 16 to match production, removes a stale Dockerfile, and carves out an explicit exception for the library's `sqlite3://:memory:` DSN which Go 1.26's stricter `net/url.Parse` now rejects. ### Go toolchain bump - `go.mod` directive bumped to `go 1.26.0` - `.github/workflows/test.yml`, `.github/workflows/check-go-generate.yaml`, and all three build matrices in `.github/workflows/release.yml` (linux, macos-intel, macos-apple) set to `go-version: '1.26.0'` - `.claude/CLAUDE.md` project-overview line updated to reflect Go 1.26 ### CI PostgreSQL image bump - `.github/workflows/test.yml` test service image bumped from `postgis/postgis:12-3.4-alpine` to `postgis/postgis:16-3.4-alpine`. PostgreSQL 12 reached EOL in Nov 2024; PG 16 more closely matches production. The library uses no PG 13+ exclusive SQL (no `MERGE`, `JSON_TABLE`, `ANY_VALUE`, etc.), so the CI-only behavior change should be minimal. PostGIS pinned at 3.4 to keep scope tight. ### Dockerfile cleanup - Removed the top-level `Dockerfile`, which had been untouched since 2020 and was pinned to Ubuntu 18.04 (EOL) and `golang-1.12` via a third-party PPA. It was not referenced anywhere in CI. ### net/url regression in Go 1.26 Go 1.26 tightened `net/url.Parse` and now rejects `sqlite3://:memory:` because `:memory:` after `//` parses as `host:port` with a non-numeric port. This broke `TestManager_*` tests in `internal/feedstate/` and any library consumer using the same in-memory DSN form. Fix: keep `url.Parse` as the primary mechanism (preserving fragment handling, scheme case-normalization, and structural validation) and add an explicit string-equality carve-out for the one known incompatible form, shared as `tldb.sqliteMemoryDBURL`: - `tldb/adapter.go` — `newAdapter` short-circuits the sqlite memory DSN and returns the registered `sqlite3` adapter directly; all other dburls go through `url.Parse` unchanged - `tldb/common.go` — `getFvids` returns an empty fvid list for the sqlite memory DSN and otherwise parses as before; errors from `url.Parse` continue to propagate Existing tests in `internal/feedstate/manager_test.go` and `tldb/sqlite/sqlite_test.go` exercise this DSN end-to-end, so no new tests were added. The `getFvids` URL-smuggling behavior is preserved in case external consumers of transitland-lib rely on it. ### Workflow hygiene - `.github/workflows/check-go-generate.yaml` — bumped `actions/github-script@v6` to `@v7` for consistency with `release.yml` ## Test plan - Confirm `go version` reports 1.26.x locally before building - `go mod tidy` produces no diff - `go vet ./...` is clean - `(cd cmd/transitland && go build .)` succeeds - `go test ./internal/feedstate/... ./tldb/...` passes (previously failing on 1.26) - Full test suite passes in CI against PG 16 / PostGIS 3.4 - Verify CI jobs run on 1.26.0: Test Suite, Check Generated Code, and on a tagged release the linux / macos-intel / macos-apple build jobs
1 parent 18eb352 commit 489439d

8 files changed

Lines changed: 28 additions & 33 deletions

File tree

.claude/CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
66

77
`transitland-lib` is a Go library and CLI tool for reading, writing, and processing transit data in GTFS and related formats. It provides CSV/database readers and writers, a transformation pipeline (copier), GTFS validation, a GraphQL/REST web API, and DMFR (Distributed Mobility Feed Registry) support.
88

9-
**Go 1.24.2** | PostgreSQL/PostGIS | SQLite (requires CGO) | GraphQL (gqlgen) | Cobra CLI
9+
**Go 1.26** | PostgreSQL/PostGIS | SQLite (requires CGO) | GraphQL (gqlgen) | Cobra CLI
1010

1111
## Build & Test Commands
1212

.github/workflows/check-go-generate.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Set up Go
2222
uses: actions/setup-go@v5
2323
with:
24-
go-version: '1.24.2'
24+
go-version: '1.26.0'
2525

2626
- name: Install protoc
2727
run: |
@@ -49,7 +49,7 @@ jobs:
4949
fi
5050
5151
- name: Comment on PR
52-
uses: actions/github-script@v6
52+
uses: actions/github-script@v7
5353
if: steps.check_changes.outputs.has_changes == 'true'
5454
with:
5555
script: |
@@ -100,7 +100,7 @@ jobs:
100100
}
101101
102102
- name: Update success comment
103-
uses: actions/github-script@v6
103+
uses: actions/github-script@v7
104104
if: steps.check_changes.outputs.has_changes != 'true'
105105
with:
106106
script: |

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
runs-on: ubuntu-latest
4747
strategy:
4848
matrix:
49-
go-version: ['1.24.2']
49+
go-version: ['1.26.0']
5050
steps:
5151
- name: Checkout
5252
uses: actions/checkout@v4
@@ -69,7 +69,7 @@ jobs:
6969
runs-on: macos-15-large # macOS on Intel
7070
strategy:
7171
matrix:
72-
go-version: ['1.24.2']
72+
go-version: ['1.26.0']
7373
steps:
7474
- name: Checkout
7575
uses: actions/checkout@v4
@@ -109,7 +109,7 @@ jobs:
109109
runs-on: macos-15 # macOS on Apple Silicon
110110
strategy:
111111
matrix:
112-
go-version: ['1.24.2']
112+
go-version: ['1.26.0']
113113
steps:
114114
- name: Checkout
115115
uses: actions/checkout@v4

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ jobs:
2121
strategy:
2222
matrix:
2323
os: [ubuntu-latest] # , macos-15
24-
go-version: ['1.24.2']
24+
go-version: ['1.26.0']
2525
runs-on: ${{ matrix.os }}
2626
env:
2727
TL_TEST_DATABASE_URL: postgres://root:for_testing@localhost:5432/tlv2_test?sslmode=disable
2828
TL_TEST_SERVER_DATABASE_URL: postgres://root:for_testing@localhost:5432/tlv2_test_server?sslmode=disable
2929
TL_REDIS_URL: redis://localhost
3030
services:
3131
postgres:
32-
image: postgis/postgis:12-3.4-alpine
32+
image: postgis/postgis:16-3.4-alpine
3333
ports:
3434
- 5432:5432
3535
env:

Dockerfile

Lines changed: 0 additions & 19 deletions
This file was deleted.

go.mod

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

3-
go 1.24.2
3+
go 1.26.0
44

55
require (
66
github.com/99designs/gqlgen v0.17.78

tldb/adapter.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,27 @@ import (
99

1010
var adapterFactories = map[string]func(string) Adapter{}
1111

12+
// sqliteMemoryDBURL is the sqlite in-memory DSN used throughout this library.
13+
// Go 1.26 tightened net/url and now rejects it because ":memory:" after the
14+
// authority marker parses as host:port with a non-numeric port. It is carved
15+
// out explicitly rather than loosening url.Parse handling in general.
16+
const sqliteMemoryDBURL = "sqlite3://:memory:"
17+
1218
func RegisterAdapter(name string, fn func(string) Adapter) {
1319
adapterFactories[name] = fn
1420
}
1521

1622
// newAdapter returns a Adapter for the given dburl.
1723
func newAdapter(dburl string) Adapter {
18-
u, err := url.Parse(dburl)
19-
if err != nil {
20-
return nil
24+
scheme := "sqlite3"
25+
if dburl != sqliteMemoryDBURL {
26+
u, err := url.Parse(dburl)
27+
if err != nil {
28+
return nil
29+
}
30+
scheme = u.Scheme
2131
}
22-
fn, ok := adapterFactories[u.Scheme]
32+
fn, ok := adapterFactories[scheme]
2333
if !ok {
2434
return nil
2535
}

tldb/common.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ func check(err error) {
133133
}
134134

135135
func getFvids(dburl string) ([]int, string, error) {
136+
// See adapter.go for why this one DSN form is carved out.
137+
if dburl == sqliteMemoryDBURL {
138+
return []int{}, dburl, nil
139+
}
136140
fvids := []int{}
137141
u, err := url.Parse(dburl)
138142
if err != nil {

0 commit comments

Comments
 (0)