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>
Marcin Rataj committed
Feb 11, 2026 at 00:08 UTC
36c29c55f02fc5bb22b0e3c4e08911d96905ad38
10 files changed
+24
-13
Dockerfile
+1
-1
@@ -1,6 +1,6 @@
1
# syntax=docker/dockerfile:1
2
# 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
4
5
ARG TARGETOS TARGETARCH
6
config/autoconf.go
+2
-2
@@ -2,7 +2,7 @@ package config
2
3
import (
4
"maps"
5
- "math/rand"
5
+ "math/rand/v2"
6
"strings"
7
8
"github.com/ipfs/boxo/autoconf"
@@ -70,7 +70,7 @@ func selectRandomResolver(resolvers []string) string {
70
if len(resolvers) == 0 {
71
return ""
72
}
73
- return resolvers[rand.Intn(len(resolvers))]
73
+ return resolvers[rand.IntN(len(resolvers))]
74
}
75
76
// DNSResolversWithAutoConf returns DNS resolvers with "auto" values replaced by autoconf values
core/commands/name/name.go
+1
-1
@@ -234,7 +234,7 @@ Passing --verify will verify signature against provided public key.
234
}
235
236
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)
238
}
239
240
if out.Entry.Validity != nil {
core/commands/provide.go
+1
-2
@@ -351,8 +351,7 @@ NOTES:
351
}
352
sectionTitle := func(col int, title string) {
353
if !brief && showHeadings {
354
- //nolint:govet // dynamic format string is intentional
355
- formatLine(col, title+":")
354
+ formatLine(col, "%s:", title)
355
}
356
}
357
core/corehttp/p2p_proxy.go
+7
-2
@@ -35,8 +35,13 @@ func P2PProxyOption() ServeOption {
35
}
36
37
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
+ }
45
proxy.ServeHTTP(w, request)
46
})
47
return mux, nil
docs/changelogs/v0.40.md
+7
@@ -32,6 +32,7 @@ This release was brought to you by the [Shipyard](https://ipshipyard.com/) team.
32
- [🖥️ WebUI Improvements](#-webui-improvements)
33
- [📢 libp2p announces all interface addresses](#-libp2p-announces-all-interface-addresses)
34
- [🗑️ Badger v1 datastore slated for removal this year](#-badger-v1-datastore-slated-for-removal-this-year)
35
+ - [🐹 Go 1.26](#-go-126)
36
- [📦️ Dependency updates](#-dependency-updates)
37
- [📝 Changelog](#-changelog)
38
- [👨👩👧👦 Contributors](#-contributors)
@@ -320,6 +321,12 @@ The `badgerds` datastore (based on badger 1.x) is slated for removal. Badger v1
321
322
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.
323
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
+
330
#### 📦️ Dependency updates
331
332
- 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
+1
-1
@@ -1,6 +1,6 @@
1
module github.com/ipfs/kubo/examples/kubo-as-a-library
2
3
-go 1.25
3
+go 1.26
4
5
// Used to keep this in sync with the current version of kubo. You should remove
6
// this if you copy this example.
go.mod
+1
-1
@@ -1,6 +1,6 @@
1
module github.com/ipfs/kubo
2
3
-go 1.25
3
+go 1.26
4
5
require (
6
bazil.org/fuse v0.0.0-20200117225306-7b5117fecadc
test/cli/gateway_test.go
+2
-2
@@ -215,13 +215,13 @@ func TestGateway(t *testing.T) {
215
t.Run("GET /webui returns 301 or 302", func(t *testing.T) {
216
t.Parallel()
217
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)
219
})
220
221
t.Run("GET /webui/ returns 301 or 302", func(t *testing.T) {
222
t.Parallel()
223
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)
225
})
226
227
t.Run("GET /webui/ returns user-specified headers", func(t *testing.T) {
test/dependencies/go.mod
+1
-1
@@ -1,6 +1,6 @@
1
module github.com/ipfs/kubo/test/dependencies
2
3
-go 1.25
3
+go 1.26
4
5
replace github.com/ipfs/kubo => ../../
6