Skip to content

Commit 6350f6a

Browse files
chore: upgrade to go1.26.0 and implement various fixes to rules, allocations, correctness etc (#149)
1 parent f9b497a commit 6350f6a

25 files changed

Lines changed: 557 additions & 405 deletions

.github/workflows/ci.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Setup Go with caching
2424
uses: actions/setup-go@v6
2525
with:
26-
go-version-file: "go.mod"
26+
go-version-file: "go.work"
2727
cache: true
2828

2929
- name: Check code formatting
@@ -57,7 +57,7 @@ jobs:
5757
- name: Setup Go with caching
5858
uses: actions/setup-go@v6
5959
with:
60-
go-version-file: "go.mod"
60+
go-version-file: "go.work"
6161
cache: true
6262

6363
# Verify Docker is available for testcontainers (Ubuntu only)
@@ -111,7 +111,7 @@ jobs:
111111
- name: Setup Go with caching
112112
uses: actions/setup-go@v6
113113
with:
114-
go-version-file: "go.mod"
114+
go-version-file: "go.work"
115115
cache: true
116116

117117
# Verify Docker is available for testcontainers
@@ -229,7 +229,7 @@ jobs:
229229
- name: Setup Go with caching
230230
uses: actions/setup-go@v6
231231
with:
232-
go-version-file: "go.mod"
232+
go-version-file: "go.work"
233233
cache: true
234234

235235
- name: Build project
@@ -250,7 +250,7 @@ jobs:
250250
- name: Setup Go with caching
251251
uses: actions/setup-go@v6
252252
with:
253-
go-version-file: "go.mod"
253+
go-version-file: "go.work"
254254
cache: true
255255

256256
- name: Build project
@@ -272,7 +272,7 @@ jobs:
272272
- name: Setup Go with caching
273273
uses: actions/setup-go@v6
274274
with:
275-
go-version-file: "go.mod"
275+
go-version-file: "go.work"
276276
cache: true
277277

278278
- name: Run CLI integration tests

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Setup Go
2626
uses: actions/setup-go@v6
2727
with:
28-
go-version-file: "go.mod"
28+
go-version-file: "go.work"
2929
cache: true
3030

3131
- name: Run tests
Lines changed: 123 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,130 @@
11
name: Update Submodule Dependencies
22

33
on:
4-
push:
5-
branches: [main]
6-
# Only run if changes affect the root module (not submodules themselves)
7-
paths-ignore:
8-
- "cmd/openapi/**"
9-
- "openapi/linter/customrules/**"
10-
- "openapi/linter/converter/tests/**"
11-
- ".github/workflows/update-submodule-dependencies.yaml"
4+
push:
5+
branches: [main]
6+
# Only run if changes affect the root module (not submodules themselves)
7+
paths-ignore:
8+
- "cmd/openapi/**"
9+
- "openapi/linter/customrules/**"
10+
- "openapi/linter/converter/tests/**"
11+
- ".github/workflows/update-submodule-dependencies.yaml"
1212

1313
permissions:
14-
contents: write
15-
pull-requests: write
14+
contents: write
15+
pull-requests: write
1616

1717
jobs:
18-
update-dependencies:
19-
name: Update submodule dependencies
20-
runs-on: ubuntu-latest
21-
steps:
22-
- uses: actions/checkout@v6
23-
24-
- name: Setup Go
25-
uses: actions/setup-go@v6
26-
with:
27-
go-version-file: "go.mod"
28-
cache: false # Disable caching to ensure fresh dependency resolution
29-
30-
- name: Update openapi/linter/customrules go.mod
31-
run: |
32-
cd openapi/linter/customrules
33-
34-
# Update to latest main commit
35-
go get github.com/speakeasy-api/openapi@main
36-
go mod tidy
37-
38-
- name: Update openapi/linter/converter/tests go.mod
39-
run: |
40-
cd openapi/linter/converter/tests
41-
42-
# Update to latest main commit (both main module and customrules)
43-
go get github.com/speakeasy-api/openapi@main
44-
go get github.com/speakeasy-api/openapi/openapi/linter/customrules@main
45-
go mod tidy
46-
47-
- name: Update cmd/openapi go.mod
48-
run: |
49-
cd cmd/openapi
50-
51-
# Update to latest main commit (both main module and customrules)
52-
go get github.com/speakeasy-api/openapi@main
53-
go get github.com/speakeasy-api/openapi/openapi/linter/customrules@main
54-
go mod tidy
55-
56-
- name: Check for changes
57-
id: changes
58-
run: |
59-
CHANGED_FILES=""
60-
61-
# Check customrules module
62-
if ! git diff --quiet openapi/linter/customrules/go.mod openapi/linter/customrules/go.sum 2>/dev/null; then
63-
CHANGED_FILES="${CHANGED_FILES}customrules "
64-
fi
65-
66-
# Check converter/tests module
67-
if ! git diff --quiet openapi/linter/converter/tests/go.mod openapi/linter/converter/tests/go.sum 2>/dev/null; then
68-
CHANGED_FILES="${CHANGED_FILES}converter-tests "
69-
fi
70-
71-
# Check cmd/openapi module
72-
if ! git diff --quiet cmd/openapi/go.mod cmd/openapi/go.sum 2>/dev/null; then
73-
CHANGED_FILES="${CHANGED_FILES}cmd "
74-
fi
75-
76-
if [ -z "$CHANGED_FILES" ]; then
77-
echo "changed=false" >> $GITHUB_OUTPUT
78-
echo "No changes detected"
79-
else
80-
echo "changed=true" >> $GITHUB_OUTPUT
81-
echo "modules=${CHANGED_FILES}" >> $GITHUB_OUTPUT
82-
echo "Changes detected in: ${CHANGED_FILES}"
83-
84-
# Get the new version for the PR description
85-
NEW_VERSION=$(grep 'github.com/speakeasy-api/openapi v' cmd/openapi/go.mod | head -1 | awk '{print $2}')
86-
echo "version=${NEW_VERSION}" >> $GITHUB_OUTPUT
87-
echo "Updated to version: ${NEW_VERSION}"
88-
fi
89-
90-
- name: Create Pull Request
91-
if: steps.changes.outputs.changed == 'true'
92-
uses: peter-evans/create-pull-request@v8
93-
with:
94-
token: ${{ secrets.GITHUB_TOKEN }}
95-
commit-message: |
96-
chore: update submodule dependencies to latest main
97-
98-
Updates go.mod files in submodules to use the latest commit from main.
99-
Version: ${{ steps.changes.outputs.version }}
100-
Updated modules: ${{ steps.changes.outputs.modules }}
101-
branch: bot/update-submodule-dependencies
102-
delete-branch: true
103-
title: "chore: update submodule dependencies to latest main"
104-
body: |
105-
## Updates submodule dependencies
106-
107-
This PR updates the `go.mod` files in submodules to reference the latest commit from main.
108-
109-
**Updated to:** `${{ steps.changes.outputs.version }}`
110-
**Updated modules:** ${{ steps.changes.outputs.modules }}
111-
112-
**Changes:**
113-
- Updated `github.com/speakeasy-api/openapi` dependency in submodule go.mod files
114-
- Ran `go mod tidy` to update dependencies
115-
116-
---
117-
*This PR was automatically created by the [update-submodule-dependencies workflow](.github/workflows/update-submodule-dependencies.yaml)*
118-
labels: |
119-
dependencies
120-
automated
121-
122-
- name: Summary
123-
run: |
124-
if [ "${{ steps.changes.outputs.changed }}" == "true" ]; then
125-
echo "✅ Pull request created to update submodule dependencies"
126-
echo "Version: ${{ steps.changes.outputs.version }}"
127-
echo "Modules: ${{ steps.changes.outputs.modules }}"
128-
else
129-
echo "ℹ️ No changes needed - submodule dependencies already up to date"
130-
fi
18+
update-dependencies:
19+
name: Update submodule dependencies
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v6
23+
24+
- name: Setup Go
25+
uses: actions/setup-go@v6
26+
with:
27+
go-version-file: "go.work"
28+
cache: false # Disable caching to ensure fresh dependency resolution
29+
30+
- name: Update openapi/linter/customrules go.mod
31+
run: |
32+
cd openapi/linter/customrules
33+
34+
# Update to latest main commit
35+
go get github.com/speakeasy-api/openapi@main
36+
go mod tidy
37+
38+
- name: Update openapi/linter/converter/tests go.mod
39+
run: |
40+
cd openapi/linter/converter/tests
41+
42+
# Update to latest main commit (both main module and customrules)
43+
go get github.com/speakeasy-api/openapi@main
44+
go get github.com/speakeasy-api/openapi/openapi/linter/customrules@main
45+
go mod tidy
46+
47+
- name: Update cmd/openapi go.mod
48+
run: |
49+
cd cmd/openapi
50+
51+
# Update to latest main commit (both main module and customrules)
52+
go get github.com/speakeasy-api/openapi@main
53+
go get github.com/speakeasy-api/openapi/openapi/linter/customrules@main
54+
go mod tidy
55+
56+
- name: Check for changes
57+
id: changes
58+
run: |
59+
CHANGED_FILES=""
60+
61+
# Check customrules module
62+
if ! git diff --quiet openapi/linter/customrules/go.mod openapi/linter/customrules/go.sum 2>/dev/null; then
63+
CHANGED_FILES="${CHANGED_FILES}customrules "
64+
fi
65+
66+
# Check converter/tests module
67+
if ! git diff --quiet openapi/linter/converter/tests/go.mod openapi/linter/converter/tests/go.sum 2>/dev/null; then
68+
CHANGED_FILES="${CHANGED_FILES}converter-tests "
69+
fi
70+
71+
# Check cmd/openapi module
72+
if ! git diff --quiet cmd/openapi/go.mod cmd/openapi/go.sum 2>/dev/null; then
73+
CHANGED_FILES="${CHANGED_FILES}cmd "
74+
fi
75+
76+
if [ -z "$CHANGED_FILES" ]; then
77+
echo "changed=false" >> $GITHUB_OUTPUT
78+
echo "No changes detected"
79+
else
80+
echo "changed=true" >> $GITHUB_OUTPUT
81+
echo "modules=${CHANGED_FILES}" >> $GITHUB_OUTPUT
82+
echo "Changes detected in: ${CHANGED_FILES}"
83+
84+
# Get the new version for the PR description
85+
NEW_VERSION=$(grep 'github.com/speakeasy-api/openapi v' cmd/openapi/go.mod | head -1 | awk '{print $2}')
86+
echo "version=${NEW_VERSION}" >> $GITHUB_OUTPUT
87+
echo "Updated to version: ${NEW_VERSION}"
88+
fi
89+
90+
- name: Create Pull Request
91+
if: steps.changes.outputs.changed == 'true'
92+
uses: peter-evans/create-pull-request@v8
93+
with:
94+
token: ${{ secrets.GITHUB_TOKEN }}
95+
commit-message: |
96+
chore: update submodule dependencies to latest main
97+
98+
Updates go.mod files in submodules to use the latest commit from main.
99+
Version: ${{ steps.changes.outputs.version }}
100+
Updated modules: ${{ steps.changes.outputs.modules }}
101+
branch: bot/update-submodule-dependencies
102+
delete-branch: true
103+
title: "chore: update submodule dependencies to latest main"
104+
body: |
105+
## Updates submodule dependencies
106+
107+
This PR updates the `go.mod` files in submodules to reference the latest commit from main.
108+
109+
**Updated to:** `${{ steps.changes.outputs.version }}`
110+
**Updated modules:** ${{ steps.changes.outputs.modules }}
111+
112+
**Changes:**
113+
- Updated `github.com/speakeasy-api/openapi` dependency in submodule go.mod files
114+
- Ran `go mod tidy` to update dependencies
115+
116+
---
117+
*This PR was automatically created by the [update-submodule-dependencies workflow](.github/workflows/update-submodule-dependencies.yaml)*
118+
labels: |
119+
dependencies
120+
automated
121+
122+
- name: Summary
123+
run: |
124+
if [ "${{ steps.changes.outputs.changed }}" == "true" ]; then
125+
echo "✅ Pull request created to update submodule dependencies"
126+
echo "Version: ${{ steps.changes.outputs.version }}"
127+
echo "Modules: ${{ steps.changes.outputs.modules }}"
128+
else
129+
echo "ℹ️ No changes needed - submodule dependencies already up to date"
130+
fi

.mise.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tools]
2-
go = "1.24.3"
2+
go = "1.26.0"
33
gotestsum = "latest"
44

55
[tasks.setup-vscode-symlinks]
@@ -13,7 +13,7 @@ run = [
1313
postinstall = [
1414
"ln -sf ./AGENTS.md ./CLAUDE.md",
1515
"git submodule update --init --recursive",
16-
"mise exec go@1.24.3 -- go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.7.2",
16+
"mise exec go@1.26.0 -- go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.7.2",
1717
"mise run setup-vscode-symlinks",
1818
"go install go.uber.org/nilaway/cmd/nilaway@8ad05f0",
1919
]

go.work

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
go 1.24.3
1+
go 1.26.0
22

33
use (
44
.

hashing/hashing.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,19 @@ func Hash(v any) string {
1616
hasher := fnv.New64a()
1717
hashableStr := toHashableString(v)
1818
_, _ = hasher.Write([]byte(hashableStr))
19-
return fmt.Sprintf("%016x", hasher.Sum64())
19+
return formatHash(hasher.Sum64())
20+
}
21+
22+
// formatHash converts a uint64 hash to a zero-padded 16-character hex string
23+
// without the allocation overhead of fmt.Sprintf.
24+
func formatHash(h uint64) string {
25+
const hexDigits = "0123456789abcdef"
26+
var buf [16]byte
27+
for i := 15; i >= 0; i-- {
28+
buf[i] = hexDigits[h&0xf]
29+
h >>= 4
30+
}
31+
return string(buf[:])
2032
}
2133

2234
type model interface {
@@ -88,6 +100,14 @@ func toHashableString(v any) string {
88100
builder.WriteString(v)
89101
case int:
90102
builder.WriteString(strconv.Itoa(v))
103+
case int64:
104+
builder.WriteString(strconv.FormatInt(v, 10))
105+
case float64:
106+
builder.WriteString(strconv.FormatFloat(v, 'f', -1, 64))
107+
case bool:
108+
builder.WriteString(strconv.FormatBool(v))
109+
case uint64:
110+
builder.WriteString(strconv.FormatUint(v, 10))
91111
case *yaml.Node:
92112
builder.WriteString(yamlNodeToHashableString(v))
93113
default:
@@ -160,7 +180,8 @@ func yamlNodeToHashableString(node *yaml.Node) string {
160180
var builder strings.Builder
161181

162182
// Include semantic fields only
163-
builder.WriteString(fmt.Sprintf("Kind%d", node.Kind))
183+
builder.WriteString("Kind")
184+
builder.WriteString(strconv.Itoa(int(node.Kind)))
164185
if node.Tag != "" {
165186
builder.WriteString("Tag" + node.Tag)
166187
}

0 commit comments

Comments
 (0)