Skip to content

Commit 656a0a0

Browse files
committedMar 11, 2025·
go.mod, misc: update to go 1.24
Change-Id: Iba3d15376214048113314150944d3b0df187a8cf Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/656475 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> kokoro-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
1 parent 38e0570 commit 656a0a0

File tree

11 files changed

+33
-34
lines changed

11 files changed

+33
-34
lines changed
 

‎cmd/internal/pkgsite/server.go

+1-13
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"os"
1515
"os/exec"
1616
"path/filepath"
17-
"runtime"
1817
"sort"
1918
"strings"
2019
"time"
@@ -243,7 +242,7 @@ func buildGetters(ctx context.Context, cfg getterConfig) ([]fetch.ModuleGetter,
243242
if cfg.useLocalStdlib {
244243
goRepo := cfg.goRepoPath
245244
if goRepo == "" {
246-
goRepo = getGOROOT()
245+
goRepo = internal.GOROOT()
247246
}
248247
if goRepo != "" { // if goRepo == "" we didn't get a *goRepoPath and couldn't find GOROOT. Fall back to the zip files.
249248
mg, err := fetch.NewGoPackagesStdlibModuleGetter(ctx, goRepo)
@@ -265,17 +264,6 @@ func buildGetters(ctx context.Context, cfg getterConfig) ([]fetch.ModuleGetter,
265264
return getters, nil
266265
}
267266

268-
func getGOROOT() string {
269-
if rg := runtime.GOROOT(); rg != "" {
270-
return rg
271-
}
272-
b, err := exec.Command("go", "env", "GOROOT").Output()
273-
if err != nil {
274-
return ""
275-
}
276-
return strings.TrimSpace(string(b))
277-
}
278-
279267
func newServer(getters []fetch.ModuleGetter, localModules []frontend.LocalModule, prox *proxy.Client, devMode bool, staticFlag string) (*frontend.Server, error) {
280268
lds := fetchdatasource.Options{
281269
Getters: getters,

‎deploy/deploy-env.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ steps:
2222
args:
2323
- $PROJECT_ID
2424
- id: Check redistributable
25-
name: golang:1.23
25+
name: golang:1.24
2626
entrypoint: private/devtools/check_redist.sh
2727
- id: Build
2828
name: gcr.io/cloud-builders/docker
@@ -48,7 +48,7 @@ steps:
4848
- -c
4949
- deploy/frontend.sh $_ENV gcr.io/$PROJECT_ID/frontend:$(cat _BUILD_TAG)
5050
- id: Pagecheck
51-
name: golang:1.23
51+
name: golang:1.24
5252
entrypoint: deploy/pagecheck.sh
5353
args:
5454
- $_ENV

‎deploy/deploy.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ steps:
2222
args:
2323
- $PROJECT_ID
2424
- id: Check redistributable
25-
name: golang:1.23
25+
name: golang:1.24
2626
entrypoint: private/devtools/check_redist.sh
2727
- id: Build
2828
name: gcr.io/cloud-builders/docker
@@ -48,7 +48,7 @@ steps:
4848
- -c
4949
- deploy/frontend.sh staging gcr.io/$PROJECT_ID/frontend:$(cat _BUILD_TAG)
5050
- id: Pagecheck - staging
51-
name: golang:1.23
51+
name: golang:1.24
5252
entrypoint: deploy/pagecheck.sh
5353
args:
5454
- staging
@@ -77,7 +77,7 @@ steps:
7777
- -c
7878
- deploy/frontend.sh prod gcr.io/$PROJECT_ID/frontend:$(cat _BUILD_TAG)
7979
- id: Pagecheck - prod
80-
name: golang:1.23
80+
name: golang:1.24
8181
entrypoint: deploy/pagecheck.sh
8282
args:
8383
- prod
@@ -88,7 +88,7 @@ steps:
8888
- -c
8989
- deploy/frontend.sh beta gcr.io/$PROJECT_ID/frontend:$(cat _BUILD_TAG)
9090
- id: Pagecheck - beta
91-
name: golang:1.23
91+
name: golang:1.24
9292
entrypoint: deploy/pagecheck.sh
9393
args:
9494
- beta

‎deploy/migrate.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ steps:
1616
args:
1717
- $PROJECT_ID
1818
- id: Migrate
19-
name: golang:1.23
19+
name: golang:1.24
2020
entrypoint: bash
2121
dir: private
2222
args:

‎deploy/sitemap.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ steps:
99
args:
1010
- $PROJECT_ID
1111
- id: Build
12-
name: golang:1.23
12+
name: golang:1.24
1313
entrypoint: bash
1414
dir: private
1515
args:

‎devtools/docker/compose.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030
depends_on:
3131
- db
3232
# This should match the version we are using on Cloud Run.
33-
image: golang:1.23
33+
image: golang:1.24
3434
environment:
3535
<<: [*database-variables, *go-variables]
3636
GO_DISCOVERY_TESTDB: ${GO_DISCOVERY_TESTDB:-"true"}
@@ -41,7 +41,7 @@ services:
4141
- ../../:/pkgsite
4242
working_dir: /pkgsite
4343
searchtest:
44-
image: golang:1.23
44+
image: golang:1.24
4545
depends_on:
4646
- frontend
4747
environment:
@@ -52,7 +52,7 @@ services:
5252
- ../../:/pkgsite
5353
working_dir: /pkgsite
5454
api:
55-
image: golang:1.23
55+
image: golang:1.24
5656
depends_on:
5757
- frontend
5858
environment:
@@ -64,7 +64,7 @@ services:
6464
working_dir: /pkgsite
6565
frontend:
6666
# This should match the version we are using on AppEngine.
67-
image: golang:1.23
67+
image: golang:1.24
6868
depends_on:
6969
- db
7070
command: bash -c "
@@ -81,7 +81,7 @@ services:
8181
working_dir: /pkgsite
8282
seeddb:
8383
# This should match the version we are using on Cloud Run.
84-
image: golang:1.23
84+
image: golang:1.24
8585
depends_on:
8686
- db
8787
# Note: technically we should check that migrations have completed before
@@ -134,7 +134,7 @@ services:
134134
shm_size: 8G
135135
go:
136136
# This should match the version we are using on Cloud Run.
137-
image: golang:1.23
137+
image: golang:1.24
138138
entrypoint: go
139139
environment:
140140
<<: [*database-variables, *go-variables]

‎go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module golang.org/x/pkgsite
22

3-
go 1.23.0
3+
go 1.24.1
44

55
require (
66
cloud.google.com/go/cloudtasks v1.10.0

‎internal/godoc/encode_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ import (
1414
"io"
1515
"path/filepath"
1616
"reflect"
17-
"runtime"
1817
"sort"
1918
"strings"
2019
"testing"
2120

2221
"github.com/google/go-cmp/cmp"
22+
"golang.org/x/pkgsite/internal"
2323
)
2424

25-
var packageToTest string = filepath.Join(runtime.GOROOT(), "src", "net", "http")
25+
var packageToTest string = filepath.Join(internal.GOROOT(), "src", "net", "http")
2626

2727
func TestEncodeDecodePackage(t *testing.T) {
2828
p, err := packageForDir(packageToTest, true)

‎internal/symbol/apigodoc.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ import (
1616
"fmt"
1717
"os"
1818
"path/filepath"
19-
"runtime"
2019
"sort"
2120
"strings"
2221
"unicode"
2322

2423
"golang.org/x/mod/semver"
24+
"golang.org/x/pkgsite/internal"
2525
"golang.org/x/pkgsite/internal/derrors"
2626
"golang.org/x/pkgsite/internal/stdlib"
2727
)
@@ -69,7 +69,7 @@ func ParsePackageAPIInfo(files []string) (_ apiVersions, err error) {
6969
func LoadAPIFiles(pkgPath, dir string) ([]string, error) {
7070
var apiGlob string
7171
if stdlib.Contains(pkgPath) {
72-
apiGlob = filepath.Join(filepath.Clean(runtime.GOROOT()), "api", "go*.txt")
72+
apiGlob = filepath.Join(filepath.Clean(internal.GOROOT()), "api", "go*.txt")
7373
} else {
7474
apiGlob = filepath.Join(dir, pkgPath, "v*.txt")
7575
}

‎internal/symbol/generate.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"os"
1818
"os/exec"
1919
"path/filepath"
20-
"runtime"
2120
"sort"
2221
"strings"
2322
"sync"
@@ -347,7 +346,7 @@ func (w *Walker) emitf(format string, args ...any) {
347346
// https://go.googlesource.com/go/+/refs/tags/go1.16.6/src/cmd/api/goapi.go#31,
348347
// except support for Windows is removed.
349348
func goCmd() string {
350-
path := filepath.Join(runtime.GOROOT(), "bin", "go")
349+
path := filepath.Join(internal.GOROOT(), "bin", "go")
351350
if _, err := os.Stat(path); err == nil {
352351
return path
353352
}

‎internal/util.go

+12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package internal
77
import (
88
"bufio"
99
"os"
10+
"os/exec"
1011
"strings"
1112

1213
"golang.org/x/pkgsite/internal/derrors"
@@ -37,3 +38,14 @@ func ReadFileLines(filename string) (lines []string, err error) {
3738
}
3839
return lines, nil
3940
}
41+
42+
// GOROOT returns the value of GOROOT.
43+
// It is similar to runtime.GOROOT but will work even if the binary is moved to
44+
// a different machine. (runtime.GOROOT is deprecated since 1.24 for that reason.)
45+
func GOROOT() string {
46+
b, err := exec.Command("go", "env", "GOROOT").Output()
47+
if err != nil {
48+
return ""
49+
}
50+
return strings.TrimSpace(string(b))
51+
}

0 commit comments

Comments
 (0)