+func loadTypeAliases(ctx *context, typesCtxs []*context) error {
+ for _, t := range ctx.packageData.Types {
+ for _, c := range typesCtxs {
+ if _, ok := ctx.packageData.Imports[t.Name]; ok {
+ break
+ }
+ for _, at := range c.packageData.Types {
+ if at.Name != t.Name {
+ continue
+ }
+ if len(at.Fields) != len(t.Fields) {
+ continue
+ }
+ ctx.packageData.Imports[t.Name] = Import{
+ Package: c.packageName,
+ }
+ }
+ }
+ }
+ for _, t := range ctx.packageData.Aliases {
+ for _, c := range typesCtxs {
+ if _, ok := ctx.packageData.Imports[t.Name]; ok {
+ break
+ }
+ for _, at := range c.packageData.Aliases {
+ if at.Name != t.Name {
+ continue
+ }
+ if at.Length != t.Length {
+ continue
+ }
+ if at.Type != t.Type {
+ continue
+ }
+ ctx.packageData.Imports[t.Name] = Import{
+ Package: c.packageName,
+ }
+ }
+ }
+ }
+ for _, t := range ctx.packageData.Enums {
+ for _, c := range typesCtxs {
+ if _, ok := ctx.packageData.Imports[t.Name]; ok {
+ break
+ }
+ for _, at := range c.packageData.Enums {
+ if at.Name != t.Name {
+ continue
+ }
+ if at.Type != t.Type {
+ continue
+ }
+ ctx.packageData.Imports[t.Name] = Import{
+ Package: c.packageName,
+ }
+ }
+ }
+ }
+ for _, t := range ctx.packageData.Unions {
+ for _, c := range typesCtxs {
+ if _, ok := ctx.packageData.Imports[t.Name]; ok {
+ break
+ }
+ for _, at := range c.packageData.Unions {
+ if at.Name != t.Name {
+ continue
+ }
+ ctx.packageData.Imports[t.Name] = Import{
+ Package: c.packageName,
+ }
+ }
+ }
+ }