Skip to content

Commit 87a4019

Browse files
galarghBigLep
andauthored
chore!: upgrade to Go 1.24 (#13354)
* chore!: upgrade to Go 1.24 * chore: fix linter errors * Update the go upgrade step-by-step process docs Updated Go version references and commands in the contributing guide. --------- Co-authored-by: Steve Loeppky <[email protected]>
1 parent c8037a5 commit 87a4019

File tree

11 files changed

+50
-25
lines changed

11 files changed

+50
-25
lines changed

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ issues:
2424
# gosec
2525
- "^G101: Potential hardcoded credentials"
2626
- "^G108: Profiling endpoint is automatically exposed on /debug/pprof"
27+
- "^G115: integer overflow conversion u?int(8|32|64)? -> u?int(8|32|64)?"
2728
- "^G204: Subprocess launched with (variable|a potential tainted input or cmd arguments)"
2829
- "^G301: Expect directory permissions to be 0750 or less"
2930
- "^G302: Expect file permissions to be 0600 or less"
@@ -47,6 +48,7 @@ issues:
4748
- "^var-naming: (method|range var) \\w*(Api|Http|Id|Rpc|Url)[^\\s]* should be \\w*(API|HTTP|ID|RPC|URL)"
4849
- "^var-naming: don't use underscores in Go names"
4950
- "^var-naming: don't use ALL_CAPS in Go names; use CamelCase"
51+
- "^redefines-builtin-id: redefinition of the built-in (function|type) (max|min|cap|recover|new|error)"
5052

5153
exclude-use-default: false
5254
exclude-rules:

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
> * [CHANGELOG_1.2x.md](./documentation/changelog/CHANGELOG_1.2x.md) - v1.20.0 to v1.29.2
99
1010
# UNRELEASED
11+
- The minimum supported Golang version is now `1.24.7`
1112
- feat(gateway): expose StateGetRandomnessDigestFromBeacon ([filecoin-project/lotus#13339](https://github.com/filecoin-project/lotus/pull/13339))
1213

1314
# Node and Miner v1.34.0 / 2025-09-11

CONTRIBUTING.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,29 +126,34 @@ When updating the Go version (either patch or minor), the following files must b
126126
#### Step-by-Step Process
127127

128128
```bash
129+
OLD_GO_VERSION="1.23.7"
130+
NEW_GO_VERSION="1.23.10"
131+
129132
# Update go.mod
130-
sed -i 's/go 1.23.7/go 1.23.10/' go.mod
133+
sed -i "s/go $OLD_GO_VERSION/go $NEW_GO_VERSION/" go.mod
131134

132135
# Update GO_VERSION_MIN
133-
echo "1.23.10" > GO_VERSION_MIN
136+
echo "$NEW_GO_VERSION" > GO_VERSION_MIN
134137

135138
# Update README.md badge and documentation
136-
sed -i 's/1.23.7/1.23.10/' README.md
139+
sed -i "s/$OLD_GO_VERSION/$NEW_GO_VERSION/g" README.md
137140

138141
# Update Dockerfile
139-
sed -i 's/FROM golang:1.23.7-bullseye/FROM golang:1.23.10-bullseye/' Dockerfile
142+
sed -i "s/FROM golang:$OLD_GO_VERSION-bullseye/FROM golang:$NEW_GO_VERSION-bullseye/" Dockerfile
140143

141144
# Add a changelog entry
142145

146+
# Validate
143147
go mod tidy
144148
make build
145149
make unittests
150+
make lint
146151
```
147152

148-
149153
#### Example Reference
150154

151-
For an example of a Go patch version update, see [PR #13190](https://github.com/filecoin-project/lotus/pull/13190) which updated from Go 1.23.7 to 1.23.10.
155+
For an example of a Go patch version update, see [PR #13190](https://github.com/filecoin-project/lotus/pull/13190), which updated from Go 1.23.7 to 1.23.10.
156+
For an example of a Go minor version update, see [PR #13354](https://github.com/filecoin-project/lotus/pull/13354), which updated from Go 1.23.10 to 1.24.7.
152157

153158
### Developer Notes
154159

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#####################################
2-
FROM golang:1.23.10-bullseye AS lotus-builder
2+
FROM golang:1.24.7-bookworm AS lotus-builder
33
MAINTAINER Lotus Development Team
44

55
RUN apt-get update && apt-get install -y ca-certificates build-essential clang ocl-icd-opencl-dev ocl-icd-libopencl1 jq libhwloc-dev

GO_VERSION_MIN

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.23.10
1+
1.24.7

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $(warning Your Golang version is go$(shell expr $(GOVERSION) / 1000000).$(shell
1616
$(error Update Golang to version to at least $(shell cat GO_VERSION_MIN))
1717
endif
1818

19-
GOLANGCI_LINT_VERSION=v1.60.1
19+
GOLANGCI_LINT_VERSION=v1.64.8
2020

2121
# git modules that need to be loaded
2222
MODULES:=

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<a href="https://github.com/filecoin-project/lotus/actions/workflows/check.yml"><img src="https://github.com/filecoin-project/lotus/actions/workflows/check.yml/badge.svg"></a>
1212
<a href="https://github.com/filecoin-project/lotus/actions/workflows/test.yml"><img src="https://github.com/filecoin-project/lotus/actions/workflows/test.yml/badge.svg"></a>
1313
<a href="https://goreportcard.com/report/github.com/filecoin-project/lotus"><img src="https://goreportcard.com/badge/github.com/filecoin-project/lotus" /></a>
14-
<a href=""><img src="https://img.shields.io/badge/golang-%3E%3D1.23.10-blue.svg" /></a>
14+
<a href=""><img src="https://img.shields.io/badge/golang-%3E%3D1.24.7-blue.svg" /></a>
1515
<br>
1616
</p>
1717

@@ -58,10 +58,10 @@ For other distributions you can find the required dependencies [here.](https://l
5858

5959
#### Go
6060

61-
To build Lotus, you need a working installation of [Go 1.23.10 or higher](https://golang.org/dl/):
61+
To build Lotus, you need a working installation of [Go 1.24.7 or higher](https://golang.org/dl/):
6262

6363
```bash
64-
wget -c https://golang.org/dl/go1.23.10.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local
64+
wget -c https://golang.org/dl/go1.24.7.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local
6565
```
6666

6767
**TIP:**

api/api_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,21 @@ import (
1616
"github.com/filecoin-project/go-jsonrpc"
1717
)
1818

19+
func goRoot() (string, error) {
20+
out, err := exec.Command("go", "env", "GOROOT").Output()
21+
if err != nil {
22+
return "", err
23+
}
24+
return strings.TrimSpace(string(out)), nil
25+
}
26+
1927
func goCmd() string {
2028
var exeSuffix string
2129
if runtime.GOOS == "windows" {
2230
exeSuffix = ".exe"
2331
}
24-
path := filepath.Join(runtime.GOROOT(), "bin", "go"+exeSuffix)
32+
root, _ := goRoot()
33+
path := filepath.Join(root, "bin", "go"+exeSuffix)
2534
if _, err := os.Stat(path); err == nil {
2635
return path
2736
}

chain/types/ethtypes/rlp.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,16 @@ func encodeRLP(val interface{}) ([]byte, error) {
6060
} else if len(data) <= 55 {
6161
prefix := byte(0x80 + len(data))
6262
return append([]byte{prefix}, data...), nil
63-
} else {
64-
lenInBytes, err := encodeLength(len(data))
65-
if err != nil {
66-
return nil, err
67-
}
68-
prefix := byte(0xb7 + len(lenInBytes))
69-
return append(
70-
[]byte{prefix},
71-
append(lenInBytes, data...)...,
72-
), nil
7363
}
64+
lenInBytes, err := encodeLength(len(data))
65+
if err != nil {
66+
return nil, err
67+
}
68+
prefix := byte(0xb7 + len(lenInBytes))
69+
return append(
70+
[]byte{prefix},
71+
append(lenInBytes, data...)...,
72+
), nil
7473
case []interface{}:
7574
encodedList, err := encodeRLPListItems(data)
7675
if err != nil {

go.mod

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

3-
go 1.23.10
3+
go 1.24.7
44

55
retract v1.14.0 // Accidentally force-pushed tag, use v1.14.1+ instead.
66

0 commit comments

Comments
 (0)