diff --git a/src/cmd/go/pkg.go b/src/cmd/go/pkg.go index 7a71471340..601c30362f 100644 --- a/src/cmd/go/pkg.go +++ b/src/cmd/go/pkg.go @@ -673,10 +673,10 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package p.Target = p.target // The gc toolchain only permits C source files with cgo. - if len(p.CFiles) > 0 && !p.usesCgo() && buildContext.Compiler == "gc" { + if len(p.CFiles) > 0 && !p.usesCgo() && !p.usesSwig() && buildContext.Compiler == "gc" { p.Error = &PackageError{ ImportStack: stk.copy(), - Err: fmt.Sprintf("C source files not allowed when not using cgo: %s", strings.Join(p.CFiles, " ")), + Err: fmt.Sprintf("C source files not allowed when not using cgo or SWIG: %s", strings.Join(p.CFiles, " ")), } return p }