Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
fix: quickfix for structs that are an array of a struct which is only…
Browse files Browse the repository at this point in the history
… a pointer
  • Loading branch information
stebenz committed Nov 2, 2020
1 parent 384715c commit 9641915
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion pkg/code/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,27 @@ func getElementForStructInFile(path string, structName string, obj *object.Objec

if oki {
ty := i.Obj.Decl.(*ast.TypeSpec)
strc := ty.Type.(*ast.StructType)
sel, oksel := ty.Type.(*ast.SelectorExpr)
strc, oks := ty.Type.(*ast.StructType)
if !oks && oksel {
identX := sel.X.(*ast.Ident)

fieldObj.Fieldname = structName
fieldObj.Collection = false

importPath := modules.CachedModule(path).GetPathForImport(imports[identX.Name])
fieldObj.PackageName = filepath.Base(importPath)
subElement, err := recursiveGetElementForStruct(modules.CachedModule(importPath).CachePackage(importPath), sel.Sel.Name, fieldObj)
if err != nil {
return false
}
if subElement != nil {
if subElement.SubElements != nil {
element.SubElements = append(element.SubElements, subElement.SubElements...)
}
}
return true
}

for _, field := range strc.Fields.List {
fieldObj := &object.Object{}
Expand Down

0 comments on commit 9641915

Please sign in to comment.