Skip to content

Commit

Permalink
fix: handle another import case
Browse files Browse the repository at this point in the history
  • Loading branch information
didroe committed Mar 21, 2024
1 parent 61020b5 commit 3eb4888
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/languages/golang/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
)

var versionRegex = regexp.MustCompile(`\Av\d+\z`)
var versionSuffixRegex = regexp.MustCompile(`\.v\d+\z`)

type analyzer struct {
builder *tree.Builder
Expand Down Expand Up @@ -109,6 +110,9 @@ func (analyzer *analyzer) analyzeImportSpec(node *sitter.Node, visitChildren fun
if versionRegex.MatchString(guessedName) && len(packageName) > 1 {
guessedName = stringutil.StripQuotes((packageName[len(packageName)-2]))
}

// account for imports like `github.com/foo/bar.v3`
guessedName = versionSuffixRegex.ReplaceAllString(guessedName, "")
}

guessedName = strings.TrimSuffix(guessedName, "-go")
Expand Down

0 comments on commit 3eb4888

Please sign in to comment.