Skip to content

Commit

Permalink
refactor(parser): add v prefix for stdlib
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen committed Oct 30, 2024
1 parent b81d537 commit d5a787b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions pkg/dependency/parser/golang/mod/parse.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mod

import (
"fmt"
"io"
"regexp"
"strconv"
Expand Down Expand Up @@ -90,9 +91,11 @@ func (p *Parser) Parse(r xio.ReadSeekerAt) ([]ftypes.Package, []ftypes.Dependenc
if p.useMinVersion {
if toolchainVer := toolchainVersion(modFileParsed.Toolchain, modFileParsed.Go); toolchainVer != "" {
pkgs["stdlib"] = ftypes.Package{
ID: packageID("stdlib", toolchainVer),
Name: "stdlib",
Version: toolchainVer,
ID: packageID("stdlib", toolchainVer),
Name: "stdlib",
// Our versioning library doesn't support canonical (goX.Y.Z) format,
// So we need to add `v` prefix for consistency (with module and dependency versions).
Version: fmt.Sprintf("v%s", toolchainVer),
Relationship: ftypes.RelationshipDirect, // Considered a direct dependency as the main module depends on the standard packages.
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/dependency/parser/golang/mod/parse_testcase.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var (
{
ID: "[email protected]",
Name: "stdlib",
Version: "1.22.5",
Version: "v1.22.5",
Relationship: ftypes.RelationshipDirect,
},
{
Expand Down

0 comments on commit d5a787b

Please sign in to comment.