diff --git a/go/importer/export.go b/go/importer/export.go index 9c5eddd5..bcc9982c 100644 --- a/go/importer/export.go +++ b/go/importer/export.go @@ -350,6 +350,8 @@ func (p *exporter) field(f *types.Var) { name = f.Name() } + // qualifiedName will always emit the field package for + // anonymous fields because "" is not an exported name. p.qualifiedName(f.Pkg(), name) p.typ(f.Type()) } diff --git a/go/importer/import.go b/go/importer/import.go index afc430f8..a1edc5b8 100644 --- a/go/importer/import.go +++ b/go/importer/import.go @@ -336,6 +336,10 @@ func (p *importer) field() *types.Var { case *types.Named: obj := typ.Obj() name = obj.Name() + // correct the field package for anonymous fields + if exported(name) { + pkg = p.pkgList[0] + } default: panic("anonymous field expected") }