Fix bug that recognized "C" as a remote package.

Review Request #3170 - Created Nov. 24, 2015 and submitted

John Sirois
2616, 2619
kwlzn, mateor, stuhood
The `import "C"` statement has special semantics and imports of this
form are satisfied by the Go distribution with links to local libraries
using the C calling convention.  Pants did not recognize this and would
attempt to fetch "C" and fail since "C" is not part of the stdlib and is
also not a remote package.

This change fixes import scanning code to know about "C" and also
centralizes the import logic in `ImportOracle`.

 contrib/go/examples/src/go/cgo/BUILD                                               |  4 +++
 contrib/go/examples/src/go/cgo/main.go                                             | 12 +++++++
 contrib/go/src/python/pants/contrib/go/tasks/                        | 52 ++++++++---------------------
 contrib/go/src/python/pants/contrib/go/tasks/                           | 33 ++++--------------
 contrib/go/src/python/pants/contrib/go/tasks/                            | 90 ++++++++++++++++++++++++++++++++++++++++++++++++--
 contrib/go/tests/python/pants_test/contrib/go/tasks/BUILD                          |  9 +++++
 contrib/go/tests/python/pants_test/contrib/go/tasks/            | 36 ++++++++++++++++++++
 contrib/go/tests/python/pants_test/contrib/go/tasks/ |  5 +++
 contrib/go/tests/python/pants_test/contrib/go/tasks/               | 31 +++++++++++++++++
 contrib/go/tests/python/pants_test/contrib/go/tasks/     |  8 +++++
 contrib/go/tests/python/pants_test/contrib/go/tasks/                | 58 ++++++++++++++++++++++++++++++++
 11 files changed, 271 insertions(+), 67 deletions(-)

Added a new failing test_issues_2616 to GoFetchTest that this change
fixes as well compile and run integration tests for Cgo that aren't
directly related to this change but do exercise the full pipeline of
interest for Cgo code.

Also did not check in the motivating example since it requires ImageMagick
libs, but adding

# Auto-generated by pants!
# To re-generate run: `pants buildgen.go --materialize --remote`


Demonstrates a successful resolve and compile for remote Cgo code (the
scary output below is just 3 compile warnings in ImageMagick):

./pants compile contrib/go/examples/3rdparty/go/
09:43:02 00:00   [resolve]
09:43:02 00:00     [go]
                   Invalidated 1 target.INFO] Downloading

09:43:04 00:02       []
09:43:04 00:02   [compile]
09:43:04 00:02     [go]
                   Invalidated 1 target.
09:43:04 00:02       [install]
                     .pants.d/compile/go/ In function ‘_cgo_85b92643e208_Cfunc_IsMagickInstantiated’:
                     .pants.d/compile/go/ warning: ‘IsMagickInstantiated’ is deprecated [-Wdeprecated-declarations]
                     In file included from /usr/include/ImageMagick-6/magick/MagickCore.h:95:0,
                                      from /usr/include/ImageMagick-6/wand/MagickWand.h:72,
                                      from .pants.d/compile/go/
                     /usr/include/ImageMagick-6/magick/deprecate.h:205:3: note: declared here
                        IsMagickInstantiated(void) magick_attribute((deprecated)),
                     .pants.d/compile/go/ In function ‘_cgo_85b92643e208_Cfunc_MagickRadialBlurImage’:
                     .pants.d/compile/go/ warning: ‘MagickRadialBlurImage’ is deprecated [-Wdeprecated-declarations]
                     In file included from /usr/include/ImageMagick-6/wand/MagickWand.h:78:0,
                                      from .pants.d/compile/go/
                     /usr/include/ImageMagick-6/wand/deprecate.h:109:3: note: declared here
                        MagickRadialBlurImage(MagickWand *,const double)
                     .pants.d/compile/go/ In function ‘_cgo_85b92643e208_Cfunc_MagickRadialBlurImageChannel’:
                     .pants.d/compile/go/ warning: ‘MagickRadialBlurImageChannel’ is deprecated [-Wdeprecated-declarations]
                      // image that is added back into the original.
                     In file included from /usr/include/ImageMagick-6/wand/MagickWand.h:78:0,
                                      from .pants.d/compile/go/
                     /usr/include/ImageMagick-6/wand/deprecate.h:111:3: note: declared here
                        MagickRadialBlurImageChannel(MagickWand *,const ChannelType,const double)

09:43:14 00:12   [complete]

CI went green here:

John Sirois
Stu Hood
Chad Rhyner
John Sirois
John Sirois
John Sirois
Review request changed

Status: Closed (submitted)