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>
This commit is contained in:
Marcin Rataj 2026-02-11 00:08:28 +01:00 committed by GitHub
parent 9ca1dbb894
commit 36c29c55f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 24 additions and 13 deletions

View File

@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
# Enables BuildKit with cache mounts for faster builds
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.25 AS builder
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.26 AS builder
ARG TARGETOS TARGETARCH

View File

@ -2,7 +2,7 @@ package config
import (
"maps"
"math/rand"
"math/rand/v2"
"strings"
"github.com/ipfs/boxo/autoconf"
@ -70,7 +70,7 @@ func selectRandomResolver(resolvers []string) string {
if len(resolvers) == 0 {
return ""
}
return resolvers[rand.Intn(len(resolvers))]
return resolvers[rand.IntN(len(resolvers))]
}
// DNSResolversWithAutoConf returns DNS resolvers with "auto" values replaced by autoconf values

View File

@ -234,7 +234,7 @@ Passing --verify will verify signature against provided public key.
}
if out.Entry.ValidityType != nil {
fmt.Fprintf(tw, "Validity Type:\t%q\n", *out.Entry.ValidityType)
fmt.Fprintf(tw, "Validity Type:\t%d\n", *out.Entry.ValidityType)
}
if out.Entry.Validity != nil {

View File

@ -351,8 +351,7 @@ NOTES:
}
sectionTitle := func(col int, title string) {
if !brief && showHeadings {
//nolint:govet // dynamic format string is intentional
formatLine(col, title+":")
formatLine(col, "%s:", title)
}
}

View File

@ -35,8 +35,13 @@ func P2PProxyOption() ServeOption {
}
rt := p2phttp.NewTransport(ipfsNode.PeerHost, p2phttp.ProtocolOption(parsedRequest.name))
proxy := httputil.NewSingleHostReverseProxy(target)
proxy.Transport = rt
proxy := &httputil.ReverseProxy{
Transport: rt,
Rewrite: func(r *httputil.ProxyRequest) {
r.SetURL(target)
r.SetXForwarded()
},
}
proxy.ServeHTTP(w, request)
})
return mux, nil

View File

@ -32,6 +32,7 @@ This release was brought to you by the [Shipyard](https://ipshipyard.com/) team.
- [🖥️ WebUI Improvements](#-webui-improvements)
- [📢 libp2p announces all interface addresses](#-libp2p-announces-all-interface-addresses)
- [🗑️ Badger v1 datastore slated for removal this year](#-badger-v1-datastore-slated-for-removal-this-year)
- [🐹 Go 1.26](#-go-126)
- [📦️ Dependency updates](#-dependency-updates)
- [📝 Changelog](#-changelog)
- [👨‍👩‍👧‍👦 Contributors](#-contributors)
@ -320,6 +321,12 @@ The `badgerds` datastore (based on badger 1.x) is slated for removal. Badger v1
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.
#### 🐹 Go 1.26
This release is built with [Go 1.26](https://go.dev/doc/go1.26).
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.
#### 📦️ Dependency updates
- 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))

View File

@ -1,6 +1,6 @@
module github.com/ipfs/kubo/examples/kubo-as-a-library
go 1.25
go 1.26
// Used to keep this in sync with the current version of kubo. You should remove
// this if you copy this example.

2
go.mod
View File

@ -1,6 +1,6 @@
module github.com/ipfs/kubo
go 1.25
go 1.26
require (
bazil.org/fuse v0.0.0-20200117225306-7b5117fecadc

View File

@ -215,13 +215,13 @@ func TestGateway(t *testing.T) {
t.Run("GET /webui returns 301 or 302", func(t *testing.T) {
t.Parallel()
resp := node.APIClient().DisableRedirects().Get("/webui")
assert.Contains(t, []int{302, 301}, resp.StatusCode)
assert.Contains(t, []int{302, 301, 307, 308}, resp.StatusCode)
})
t.Run("GET /webui/ returns 301 or 302", func(t *testing.T) {
t.Parallel()
resp := node.APIClient().DisableRedirects().Get("/webui/")
assert.Contains(t, []int{302, 301}, resp.StatusCode)
assert.Contains(t, []int{302, 301, 307, 308}, resp.StatusCode)
})
t.Run("GET /webui/ returns user-specified headers", func(t *testing.T) {

View File

@ -1,6 +1,6 @@
module github.com/ipfs/kubo/test/dependencies
go 1.25
go 1.26
replace github.com/ipfs/kubo => ../../