Skip to content

Commit 6e10f8c

Browse files
authored
go/tools/gopackagesdriver: pass Compiler and Arch in DriverResponse (#3657)
go/tools/gopackagesdriver: pass Compiler and Arch in DriverResponse go/packages is being changed to expect Compiler and Arch in its DriverResponse (see golang.org/cl/516917) because we can't expect the type of the types.Sizes returned by types.Sizes to be types.StdSizes. (The default it uses when Compiler and Arch aren't set is the set of types for gc,amd64, so there's no change in behavior if those fields aren't set, but we should set them.)
1 parent f5ae196 commit 6e10f8c

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

go/tools/gopackagesdriver/json_packages_driver.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package main
1616

1717
import (
1818
"fmt"
19-
"go/types"
19+
"runtime"
2020
)
2121

2222
type JSONPackagesDriver struct {
@@ -52,7 +52,8 @@ func (b *JSONPackagesDriver) GetResponse(labels []string) *driverResponse {
5252

5353
return &driverResponse{
5454
NotHandled: false,
55-
Sizes: types.SizesFor("gc", "amd64").(*types.StdSizes),
55+
Compiler: "gc",
56+
Arch: runtime.GOARCH,
5657
Roots: rootPkgs,
5758
Packages: packages,
5859
}

go/tools/gopackagesdriver/main.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818
"context"
1919
"encoding/json"
2020
"fmt"
21-
"go/types"
2221
"os"
22+
"runtime"
2323
"strings"
2424
)
2525

@@ -31,8 +31,10 @@ type driverResponse struct {
3131
// lists of multiple drivers, go/packages will fall back to the next driver.
3232
NotHandled bool
3333

34-
// Sizes, if not nil, is the types.Sizes to use when type checking.
35-
Sizes *types.StdSizes
34+
// Compiler and Arch are the arguments pass of types.SizesFor
35+
// to get a types.Sizes to use when type checking.
36+
Compiler string
37+
Arch string
3638

3739
// Roots is the set of package IDs that make up the root packages.
3840
// We have to encode this separately because when we encode a single package
@@ -63,7 +65,8 @@ var (
6365
additionalKinds = strings.Fields(os.Getenv("GOPACKAGESDRIVER_BAZEL_KINDS"))
6466
emptyResponse = &driverResponse{
6567
NotHandled: true,
66-
Sizes: types.SizesFor("gc", "amd64").(*types.StdSizes),
68+
Compiler: "gc",
69+
Arch: runtime.GOARCH,
6770
Roots: []string{},
6871
Packages: []*FlatPackage{},
6972
}

0 commit comments

Comments
 (0)