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 <drchase@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/go/packages/packages.go b/go/packages/packages.go
index ece0e7c..3b6e58a 100644
--- a/go/packages/packages.go
+++ b/go/packages/packages.go
@@ -373,6 +373,7 @@
TypesInfo *types.Info
// TypesSizes provides the effective size function for types in TypesInfo.
+ // It may be nil if, for example, the compiler/architecture pair is not known.
TypesSizes types.Sizes
// forTest is the package under test, if any.
@@ -553,7 +554,7 @@
type loader struct {
pkgs map[string]*loaderPackage
Config
- sizes types.Sizes
+ sizes types.Sizes // nil => unknown
parseCache map[string]*parseValue
parseCacheMu sync.Mutex
exportMu sync.Mutex // enforces mutual exclusion of exportdata operations
@@ -1042,7 +1043,7 @@
IgnoreFuncBodies: ld.Mode&NeedDeps == 0 && !lpkg.initial,
Error: appendError,
- Sizes: ld.sizes,
+ Sizes: ld.sizes, // may be nil
}
if lpkg.Module != nil && lpkg.Module.GoVersion != "" {
typesinternal.SetGoVersion(tc, "go"+lpkg.Module.GoVersion)