From 70bde3e40ca06026466e3a6dd1b622e314a1e072 Mon Sep 17 00:00:00 2001 From: Nuruddin Ashr Date: Wed, 2 May 2018 01:11:45 +0700 Subject: [PATCH] Check main.go should take precedence over _test.go (#1630) --- src/util.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/util.ts b/src/util.ts index 3e8baf1a2..644208609 100644 --- a/src/util.ts +++ b/src/util.ts @@ -531,14 +531,15 @@ export function guessPackageNameFromFile(filePath): Promise { 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]); }); });