Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Check main.go should take precedence over _test.go (#1630)
Browse files Browse the repository at this point in the history
  • Loading branch information
uudashr authored and ramya-rao-a committed May 1, 2018
1 parent 98eff26 commit 70bde3e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,14 +531,15 @@ export function guessPackageNameFromFile(filePath): Promise<string[]> {

const proposedPkgName = segments[segments.length - 1];

if (goFilename.endsWith('_test.go')) {
return resolve([proposedPkgName, proposedPkgName + '_test']);
}

fs.stat(path.join(directoryPath, 'main.go'), (err, stats) => {
if (stats && stats.isFile()) {
return resolve(['main']);
}

if (goFilename.endsWith('_test.go')) {
return resolve([proposedPkgName, proposedPkgName + '_test']);
}

return resolve([proposedPkgName]);
});
});
Expand Down

0 comments on commit 70bde3e

Please sign in to comment.