diff --git a/__tests__/gobin.test.ts b/__tests__/gobin.test.ts index dc2ee48..336b36f 100644 --- a/__tests__/gobin.test.ts +++ b/__tests__/gobin.test.ts @@ -20,4 +20,12 @@ describe('gobin', () => { const gobinPath = await gobin.getGOBIN('...'); expect(gobinPath).toBe(path.join(gopath, 'bin')); }); + + it('should trim ${GOPATH} before using it', async () => { + let trimmed = gopath; + gopath = `${gopath}\r\n`; + + const gobinPath = await gobin.getGOBIN('...'); + expect(gobinPath).toBe(path.join(trimmed, 'bin')); + }); }); diff --git a/dist/index.js b/dist/index.js index fe283d6..0f27a07 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3280,7 +3280,7 @@ function getGOBIN(installDir) { return __awaiter(this, void 0, void 0, function* () { const goExecutable = path.join(installDir, 'bin', 'go'); const result = yield execFile(goExecutable, ['env', 'GOPATH']); - const gopath = result.stdout; + const gopath = result.stdout.replace(/\s+$/, ''); return path.join(gopath, 'bin'); }); } diff --git a/src/gobin.ts b/src/gobin.ts index 199c878..3677029 100644 --- a/src/gobin.ts +++ b/src/gobin.ts @@ -8,6 +8,6 @@ export async function getGOBIN(installDir: string): Promise { const goExecutable = path.join(installDir, 'bin', 'go'); const result = await execFile(goExecutable, ['env', 'GOPATH']); - const gopath = result.stdout; + const gopath = result.stdout.replace(/\s+$/, ''); return path.join(gopath, 'bin'); }