Skip to content

Commit 36c29c5

Browse files
lidelgammazero
andauthored
feat: update to Go 1.26 (#11189)
* feat: update to Go 1.26 replace deprecated httputil.NewSingleHostReverseProxy (Director) with ReverseProxy.Rewrite, switch math/rand to math/rand/v2 in production code, update Dockerfile base image. * fix test to accept response with HTTP status of 307 and 308 where 302 and 301 are expected --------- Co-authored-by: Andrew Gillis <11790789+gammazero@users.noreply.github.com>
1 parent 9ca1dbb commit 36c29c5

File tree

10 files changed

+24
-13
lines changed

10 files changed

+24
-13
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax=docker/dockerfile:1
22
# Enables BuildKit with cache mounts for faster builds
3-
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.25 AS builder
3+
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.26 AS builder
44

55
ARG TARGETOS TARGETARCH
66

config/autoconf.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package config
22

33
import (
44
"maps"
5-
"math/rand"
5+
"math/rand/v2"
66
"strings"
77

88
"github.com/ipfs/boxo/autoconf"
@@ -70,7 +70,7 @@ func selectRandomResolver(resolvers []string) string {
7070
if len(resolvers) == 0 {
7171
return ""
7272
}
73-
return resolvers[rand.Intn(len(resolvers))]
73+
return resolvers[rand.IntN(len(resolvers))]
7474
}
7575

7676
// DNSResolversWithAutoConf returns DNS resolvers with "auto" values replaced by autoconf values

core/commands/name/name.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ Passing --verify will verify signature against provided public key.
234234
}
235235

236236
if out.Entry.ValidityType != nil {
237-
fmt.Fprintf(tw, "Validity Type:\t%q\n", *out.Entry.ValidityType)
237+
fmt.Fprintf(tw, "Validity Type:\t%d\n", *out.Entry.ValidityType)
238238
}
239239

240240
if out.Entry.Validity != nil {

core/commands/provide.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,7 @@ NOTES:
351351
}
352352
sectionTitle := func(col int, title string) {
353353
if !brief && showHeadings {
354-
//nolint:govet // dynamic format string is intentional
355-
formatLine(col, title+":")
354+
formatLine(col, "%s:", title)
356355
}
357356
}
358357

core/corehttp/p2p_proxy.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ func P2PProxyOption() ServeOption {
3535
}
3636

3737
rt := p2phttp.NewTransport(ipfsNode.PeerHost, p2phttp.ProtocolOption(parsedRequest.name))
38-
proxy := httputil.NewSingleHostReverseProxy(target)
39-
proxy.Transport = rt
38+
proxy := &httputil.ReverseProxy{
39+
Transport: rt,
40+
Rewrite: func(r *httputil.ProxyRequest) {
41+
r.SetURL(target)
42+
r.SetXForwarded()
43+
},
44+
}
4045
proxy.ServeHTTP(w, request)
4146
})
4247
return mux, nil

docs/changelogs/v0.40.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ This release was brought to you by the [Shipyard](https://ipshipyard.com/) team.
3232
- [🖥️ WebUI Improvements](#-webui-improvements)
3333
- [📢 libp2p announces all interface addresses](#-libp2p-announces-all-interface-addresses)
3434
- [🗑️ Badger v1 datastore slated for removal this year](#-badger-v1-datastore-slated-for-removal-this-year)
35+
- [🐹 Go 1.26](#-go-126)
3536
- [📦️ Dependency updates](#-dependency-updates)
3637
- [📝 Changelog](#-changelog)
3738
- [👨‍👩‍👧‍👦 Contributors](#-contributors)
@@ -320,6 +321,12 @@ The `badgerds` datastore (based on badger 1.x) is slated for removal. Badger v1
320321

321322
See the [`badgerds` profile documentation](https://github.com/ipfs/kubo/blob/master/docs/config.md#badgerds-profile) for migration guidance, and [#11186](https://github.com/ipfs/kubo/issues/11186) for background.
322323

324+
#### 🐹 Go 1.26
325+
326+
This release is built with [Go 1.26](https://go.dev/doc/go1.26).
327+
328+
You should see lower memory usage and reduced GC pauses thanks to the new Green Tea garbage collector (10-40% less GC overhead). Reading block data and API responses is faster due to `io.ReadAll` improvements (~2x faster, ~50% less memory). On 64-bit platforms, heap base address randomization adds a layer of security hardening.
329+
323330
#### 📦️ Dependency updates
324331

325332
- update `go-libp2p` to [v0.47.0](https://github.com/libp2p/go-libp2p/releases/tag/v0.47.0) (incl. [v0.46.0](https://github.com/libp2p/go-libp2p/releases/tag/v0.46.0))

docs/examples/kubo-as-a-library/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/ipfs/kubo/examples/kubo-as-a-library
22

3-
go 1.25
3+
go 1.26
44

55
// Used to keep this in sync with the current version of kubo. You should remove
66
// this if you copy this example.

go.mod

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

3-
go 1.25
3+
go 1.26
44

55
require (
66
bazil.org/fuse v0.0.0-20200117225306-7b5117fecadc

test/cli/gateway_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,13 @@ func TestGateway(t *testing.T) {
215215
t.Run("GET /webui returns 301 or 302", func(t *testing.T) {
216216
t.Parallel()
217217
resp := node.APIClient().DisableRedirects().Get("/webui")
218-
assert.Contains(t, []int{302, 301}, resp.StatusCode)
218+
assert.Contains(t, []int{302, 301, 307, 308}, resp.StatusCode)
219219
})
220220

221221
t.Run("GET /webui/ returns 301 or 302", func(t *testing.T) {
222222
t.Parallel()
223223
resp := node.APIClient().DisableRedirects().Get("/webui/")
224-
assert.Contains(t, []int{302, 301}, resp.StatusCode)
224+
assert.Contains(t, []int{302, 301, 307, 308}, resp.StatusCode)
225225
})
226226

227227
t.Run("GET /webui/ returns user-specified headers", func(t *testing.T) {

test/dependencies/go.mod

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

3-
go 1.25
3+
go 1.26
44

55
replace github.com/ipfs/kubo => ../../
66

0 commit comments

Comments
 (0)