[go] cmd/go: build pkgsite directory in same go command invocation

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Apr 9, 2026, 12:24:49 PM (15 hours ago) Apr 9
to Michael Matloob, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go LUCI, Dmitri Shuralyov, Dmitri Shuralyov, Michael Matloob, Ian Alexander, golang-co...@googlegroups.com

Gopher Robot submitted the change with unreviewed changes

Unreviewed changes

5 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: src/cmd/go/internal/doc/pkgsite.go
Insertions: 8, Deletions: 1.

@@ -65,9 +65,16 @@
if err != nil {
base.Fatal(err)
}
+ if len(pkgs) == 0 {
+ base.Fatalf("go: internal error: no packages loaded for %s", pkgVers)
+ }
+ if len(pkgs) > 1 {
+ base.Fatalf("go: internal error: pattern %s matches multiple packages", pkgVers)
+ }
p := pkgs[0]
p.Internal.OmitDebug = true
p.Internal.ExeName = p.DefaultExecName()
+ load.CheckPackageErrors([]*load.Package{p})

a := b.LinkAction(loader, work.ModeBuild, work.ModeBuild, p)
a.CacheExecutable = true
@@ -116,7 +123,7 @@
env = append(env, "GOPROXY="+gomodcache+","+goproxy)
}

- pkgsite := buildPkgsite(context.Background())
+ pkgsite := buildPkgsite(ctx)
cmd := exec.Command(pkgsite, "-gorepo", cfg.GOROOT, "-http", addr, "-open", path)
cmd.Env = env
cmd.Stdout = os.Stderr
```

Change information

Commit message:
cmd/go: build pkgsite doc command in same go command invocation

Instead of running go run. This is enabled by Ian Alexander's work to
remove global state in the loader package.

This also fixes an issue where we can't build and run the pkgsite binary
because, with our GOPROXY setting, if pkgsite module is available in the
module cache at the requested version, but the pkgsite/cmd/internal/doc
module isn't we'll give up trying to fetch the doc module. Now that the
build and execution are separated, we can make sure the GOPROXY setting
is only supplied to the running pkgsite binary, but not to the
operations that build it.

Fixes #78457
Change-Id: Id2a754fee12b68240243773f81e7d00b6a6a6964
Reviewed-by: Michael Matloob <mat...@google.com>
Reviewed-by: Dmitri Shuralyov <dmit...@golang.org>
Auto-Submit: Michael Matloob <mat...@golang.org>
Reviewed-by: Dmitri Shuralyov <dmit...@google.com>
Files:
  • M src/cmd/go/internal/doc/doc.go
  • M src/cmd/go/internal/doc/pkgsite.go
  • M src/cmd/go/internal/doc/pkgsite_bootstrap.go
Change size: M
Delta: 3 files changed, 58 insertions(+), 13 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Michael Matloob, +2 by Dmitri Shuralyov, +1 by Dmitri Shuralyov
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Id2a754fee12b68240243773f81e7d00b6a6a6964
Gerrit-Change-Number: 763760
Gerrit-PatchSet: 7
Gerrit-Owner: Michael Matloob <mat...@golang.org>
Gerrit-Reviewer: Dmitri Shuralyov <dmit...@golang.org>
Gerrit-Reviewer: Dmitri Shuralyov <dmit...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Ian Alexander <ji...@google.com>
Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
Gerrit-Reviewer: Michael Matloob <mat...@google.com>
Gerrit-Reviewer: Sean Liao <se...@liao.dev>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages