Skip to content

Commit

Permalink
Merge pull request #26 from dmcgowan/update-go-mod-parsing
Browse files Browse the repository at this point in the history
Update module parsing to account for filepath
  • Loading branch information
AkihiroSuda authored Jun 19, 2021
2 parents dce8aa8 + 079f6cc commit d28c4d8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ func parseModulesTxtDependencies(r io.Reader) ([]dependency, error) {
if parts[0] != "#" {
continue
}

// See https://golang.org/ref/mod#go-mod-file-replace for
// syntax on replace directives
var commitOrVersionPart string
if len(parts) == 3 {
commitOrVersionPart = parts[2]
Expand All @@ -100,6 +103,9 @@ func parseModulesTxtDependencies(r io.Reader) ([]dependency, error) {
continue
} else if len(parts) == 6 && parts[3] == "=>" {
commitOrVersionPart = parts[5]
} else if (len(parts) == 4 && parts[2] == "=>") || (len(parts) == 5 && parts[3] == "=>") {
// Ignore replace directive which uses filepath
continue
} else {
return nil, errors.Wrapf(errUnknownFormat, "%s", ln)
}
Expand Down

0 comments on commit d28c4d8

Please sign in to comment.