Skip to content

Commit

Permalink
Fix skip cgo error because some depend struct in cgo files
Browse files Browse the repository at this point in the history
  • Loading branch information
pytimer committed Mar 14, 2022
1 parent 7c5fafd commit 0981927
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
10 changes: 3 additions & 7 deletions golist.go
Expand Up @@ -53,11 +53,6 @@ func (parser *Parser) getAllGoFileInfoFromDepsByList(pkg *build.Package) error {
return nil
}

// Skip cgo
if pkg.Name == "C" {
return nil
}

srcDir := pkg.Dir
var err error
for i := range pkg.GoFiles {
Expand All @@ -67,8 +62,9 @@ func (parser *Parser) getAllGoFileInfoFromDepsByList(pkg *build.Package) error {
}
}

for i := range pkg.CFiles {
err = parser.parseFile(pkg.ImportPath, filepath.Join(srcDir, pkg.CFiles[i]), nil)
// parse .go source files that import "C"
for i := range pkg.CgoFiles {
err = parser.parseFile(pkg.ImportPath, filepath.Join(srcDir, pkg.CgoFiles[i]), nil)
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions parser_test.go
Expand Up @@ -2130,9 +2130,8 @@ func TestParseExternalModels(t *testing.T) {
func TestParseGoList(t *testing.T) {
searchDir := "testdata/golist"
mainAPIFile := "main.go"
p := New()
p := New(ParseUsingGoList(true))
p.ParseDependency = true
p.parseGoList = true
err := p.ParseAPI(searchDir, mainAPIFile, defaultParseDepth)
assert.NoError(t, err)
}
Expand Down

0 comments on commit 0981927

Please sign in to comment.