2020-03-01 21:18:28 -05:00
|
|
|
import * as childProcess from 'child_process';
|
|
|
|
|
import * as path from 'path';
|
|
|
|
|
import {promisify} from 'util';
|
|
|
|
|
|
2020-03-01 22:06:59 -05:00
|
|
|
const execFile = promisify(childProcess.execFile);
|
2020-03-01 21:18:28 -05:00
|
|
|
|
|
|
|
|
export async function getGOBIN(installDir: string): Promise<string> {
|
|
|
|
|
const goExecutable = path.join(installDir, 'bin', 'go');
|
|
|
|
|
|
2020-03-01 22:06:59 -05:00
|
|
|
const result = await execFile(goExecutable, ['env', 'GOPATH']);
|
2020-03-01 23:59:03 -05:00
|
|
|
const gopath = result.stdout.replace(/\s+$/, '');
|
2020-03-01 21:18:28 -05:00
|
|
|
return path.join(gopath, 'bin');
|
|
|
|
|
}
|