diff --git a/go/packages/golist.go b/go/packages/golist.go index 8f678a76c0..511bc28656 100644 --- a/go/packages/golist.go +++ b/go/packages/golist.go @@ -884,6 +884,12 @@ func invokeGo(cfg *Config, args ...string) (*bytes.Buffer, error) { return nil, fmt.Errorf("%s", stderr.String()) } + // Is there an error running the C compiler in cgo? This will be reported in the "Error" field + // and should be suppressed by go list -e. + if len(stderr.String()) > 0 && strings.HasPrefix(stderr.String(), "# runtime/cgo\n") && strings.Count(stderr.String(), "\n") == 2 { + return stdout, nil + } + // This error only appears in stderr. See golang.org/cl/166398 for a fix in go list to show // the error in the Err section of stdout in case -e option is provided. // This fix is provided for backwards compatibility. diff --git a/go/packages/packages_test.go b/go/packages/packages_test.go index 42cd4f3409..5f42e6a153 100644 --- a/go/packages/packages_test.go +++ b/go/packages/packages_test.go @@ -2107,9 +2107,6 @@ func testAdHocContains(t *testing.T, exporter packagestest.Exporter) { func TestNoCcompiler(t *testing.T) { packagestest.TestAll(t, testNoCcompiler) } func testNoCcompiler(t *testing.T, exporter packagestest.Exporter) { - // Enable this test after golang/go#33462 is resolved. - t.Skip() - exported := packagestest.Export(t, exporter, []packagestest.Module{{ Name: "golang.org/fake", Files: map[string]interface{}{