Skip to content

Commit 02048e6

Browse files
committed
go/packages: document that types.Sizes may be nil
This is not a behavior change. Change-Id: Ia70c01ff0893b2274b44fb0f2043dbcb6afb71c8 Reviewed-on: https://go-review.googlesource.com/c/tools/+/537116 Reviewed-by: David Chase <[email protected]> Reviewed-by: Cuong Manh Le <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 5185da1 commit 02048e6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

go/packages/packages.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ type Package struct {
373373
TypesInfo *types.Info
374374

375375
// TypesSizes provides the effective size function for types in TypesInfo.
376+
// It may be nil if, for example, the compiler/architecture pair is not known.
376377
TypesSizes types.Sizes
377378

378379
// forTest is the package under test, if any.
@@ -553,7 +554,7 @@ type loaderPackage struct {
553554
type loader struct {
554555
pkgs map[string]*loaderPackage
555556
Config
556-
sizes types.Sizes
557+
sizes types.Sizes // nil => unknown
557558
parseCache map[string]*parseValue
558559
parseCacheMu sync.Mutex
559560
exportMu sync.Mutex // enforces mutual exclusion of exportdata operations
@@ -1042,7 +1043,7 @@ func (ld *loader) loadPackage(lpkg *loaderPackage) {
10421043
IgnoreFuncBodies: ld.Mode&NeedDeps == 0 && !lpkg.initial,
10431044

10441045
Error: appendError,
1045-
Sizes: ld.sizes,
1046+
Sizes: ld.sizes, // may be nil
10461047
}
10471048
if lpkg.Module != nil && lpkg.Module.GoVersion != "" {
10481049
typesinternal.SetGoVersion(tc, "go"+lpkg.Module.GoVersion)

0 commit comments

Comments
 (0)