From c71d9fae3372c7175bc6496ac033a01a955ceeca Mon Sep 17 00:00:00 2001 From: song Date: Fri, 14 Jun 2024 14:38:51 +0800 Subject: [PATCH] fix issue: #1780: filter $GOROOT path Signed-off-by: song --- packages.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages.go b/packages.go index 466db8629..0cd11fe77 100644 --- a/packages.go +++ b/packages.go @@ -93,7 +93,7 @@ func (pkgDefs *PackagesDefinitions) RangeFiles(handle func(info *AstFileInfo) er for _, info := range pkgDefs.files { // ignore package path prefix with 'vendor' or $GOROOT, // because the router info of api will not be included these files. - if strings.HasPrefix(info.PackagePath, "vendor") || (runtime.GOROOT() != "" && strings.HasPrefix(info.Path, runtime.GOROOT())) { + if strings.HasPrefix(info.PackagePath, "vendor") || (runtime.GOROOT() != "" && strings.HasPrefix(info.Path, runtime.GOROOT()+string(filepath.Separator))) { continue } sortedFiles = append(sortedFiles, info)