Skip to content

Commit

Permalink
Fix issue go-callvis with build tags (#139)
Browse files Browse the repository at this point in the history
* fix issue go-callvis with -tags

* remove un-needed code
  • Loading branch information
minhtrex authored May 8, 2023
1 parent 79702ce commit 39cbadb
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (a *analysis) DoAnalysis(
Mode: packages.LoadAllSyntax,
Tests: tests,
Dir: dir,
BuildFlags: build.Default.BuildTags,
BuildFlags: getBuildFlags(),
}

initial, err := packages.Load(cfg, args...)
Expand Down Expand Up @@ -375,3 +375,20 @@ func copyFile(src, dst string) (int64, error) {
nBytes, err := io.Copy(destination, source)
return nBytes, err
}

func getBuildFlags() []string {
buildFlagTags := getBuildFlagTags(build.Default.BuildTags)
if len(buildFlagTags) == 0 {
return nil
}

return []string{buildFlagTags}
}

func getBuildFlagTags(buildTags []string) string {
if len(buildTags) > 0 {
return "-tags=" + strings.Join(buildTags, ",")
}

return ""
}

0 comments on commit 39cbadb

Please sign in to comment.