Skip to content

Commit

Permalink
Merge pull request #485 from snyk/repro/windows-go-issues
Browse files Browse the repository at this point in the history
Repro/windows go issues
  • Loading branch information
tommyknows authored Apr 21, 2023
2 parents 84ff76f + 7401d21 commit b56f997
Show file tree
Hide file tree
Showing 4 changed files with 1,908 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/go-parser/go-binary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class GoBinary {
// (github.com/my/pkg@v0.0.1/a.go), the path.parse expression returns
// just a slash. This would result in a package name with a trailing
// slash, which is incorrect.
let dirName = path.parse(parts[1]).dir;
let dirName = path.posix.parse(parts[1]).dir;
if (dirName === "/") {
dirName = "";
}
Expand Down Expand Up @@ -411,7 +411,10 @@ function determineVendorPath(modules: GoModule[], files: string[]): string {
// We check for other files in that root to make sure that we really got the
// right vendor folder, and not just a random folder named `vendor` somewhere.
for (const [, mod] of Object.entries(modules)) {
const vendoredModulePath = path.join("vendor", mod.name) + "/";
// use path.posix.join so that we will always get linux-style paths even if
// the plugin runs on Windows. This is necessary because the Go binaries
// always contain linux-style path separators.
const vendoredModulePath = path.posix.join("vendor", mod.name) + "/";
const file = files.find((file) => file.includes(vendoredModulePath));
if (file) {
// make sure that we find other files in that path not in the vendor
Expand All @@ -422,7 +425,7 @@ function determineVendorPath(modules: GoModule[], files: string[]): string {
file.includes(mainModulePath) && !file.includes(vendoredModulePath),
);
if (success) {
return path.join(mainModulePath, "vendor") + "/";
return path.posix.join(mainModulePath, "vendor") + "/";
}
}
}
Expand Down
Binary file not shown.
Loading

0 comments on commit b56f997

Please sign in to comment.