From 9d2ff756b797a862da0686e2e41e09cd87da017b Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Mon, 5 Oct 2015 10:55:06 -0400 Subject: [PATCH] go/loader: document cgo limitation Change-Id: I8ce744d204fe2850d322b3095d04e8a399984983 Reviewed-on: https://go-review.googlesource.com/15391 Reviewed-by: Ian Lance Taylor --- go/loader/loader.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/go/loader/loader.go b/go/loader/loader.go index 1d3ead0d..5c87a29d 100644 --- a/go/loader/loader.go +++ b/go/loader/loader.go @@ -123,6 +123,15 @@ type Program struct { // filenames were supplied by Config.CreatePkgs[i], followed by // the external test package, if any, of each package in // Config.ImportPkgs ordered by ImportPath. + // + // NOTE: these files must not import "C". Cgo preprocessing is + // only performed on imported packages, not ad hoc packages. + // + // TODO(adonovan): we need to copy and adapt the logic of + // goFilesPackage (from $GOROOT/src/cmd/go/build.go) and make + // Config.Import and Config.Create methods return the same kind + // of entity, essentially a build.Package. + // Perhaps we can even reuse that type directly. Created []*PackageInfo // Imported contains the initially imported packages,