Skip to content

Commit 39cbadb

Browse files
authored
Fix issue go-callvis with build tags (#139)
* fix issue go-callvis with -tags * remove un-needed code
1 parent 79702ce commit 39cbadb

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Diff for: analysis.go

+18-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (a *analysis) DoAnalysis(
8181
Mode: packages.LoadAllSyntax,
8282
Tests: tests,
8383
Dir: dir,
84-
BuildFlags: build.Default.BuildTags,
84+
BuildFlags: getBuildFlags(),
8585
}
8686

8787
initial, err := packages.Load(cfg, args...)
@@ -375,3 +375,20 @@ func copyFile(src, dst string) (int64, error) {
375375
nBytes, err := io.Copy(destination, source)
376376
return nBytes, err
377377
}
378+
379+
func getBuildFlags() []string {
380+
buildFlagTags := getBuildFlagTags(build.Default.BuildTags)
381+
if len(buildFlagTags) == 0 {
382+
return nil
383+
}
384+
385+
return []string{buildFlagTags}
386+
}
387+
388+
func getBuildFlagTags(buildTags []string) string {
389+
if len(buildTags) > 0 {
390+
return "-tags=" + strings.Join(buildTags, ",")
391+
}
392+
393+
return ""
394+
}

0 commit comments

Comments
 (0)