mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
'GOCACHE' is set to '$HOME/.cache' by default. It is not portable because it relies on the users who run the kibana. Customize 'GOCACHE' to $GOPATH/.cache to make the go lsp more portable. FYI: The build cache is now required as a step toward eliminating $GOPATH/pkg.
This commit is contained in:
parent
5bc76f8438
commit
3ff0b88539
1 changed files with 9 additions and 4 deletions
|
@ -77,9 +77,12 @@ export class GoServerLauncher extends AbstractLauncher {
|
|||
}
|
||||
|
||||
async spawnProcess(installationPath: string, port: number, log: Logger) {
|
||||
const launchersFound = glob.sync('go-langserver', {
|
||||
cwd: installationPath,
|
||||
});
|
||||
const launchersFound = glob.sync(
|
||||
process.platform === 'win32' ? 'go-langserver.exe' : 'go-langserver',
|
||||
{
|
||||
cwd: installationPath,
|
||||
}
|
||||
);
|
||||
if (!launchersFound.length) {
|
||||
throw new Error('Cannot find executable go language server');
|
||||
}
|
||||
|
@ -92,12 +95,13 @@ export class GoServerLauncher extends AbstractLauncher {
|
|||
// Construct $GOROOT from the bundled go toolchain.
|
||||
const goRoot = goToolchain;
|
||||
const goHome = path.resolve(goToolchain, 'bin');
|
||||
envPath = envPath + ':' + goHome;
|
||||
envPath = process.platform === 'win32' ? envPath + ';' + goHome : envPath + ':' + goHome;
|
||||
// Construct $GOPATH under 'kibana/data/code'.
|
||||
const goPath = this.options.goPath;
|
||||
if (!fs.existsSync(goPath)) {
|
||||
fs.mkdirSync(goPath);
|
||||
}
|
||||
const goCache = path.resolve(goPath, '.cache');
|
||||
const params: string[] = ['-port=' + port.toString()];
|
||||
const golsp = path.resolve(installationPath, launchersFound[0]);
|
||||
const p = spawn(golsp, params, {
|
||||
|
@ -109,6 +113,7 @@ export class GoServerLauncher extends AbstractLauncher {
|
|||
CLIENT_PORT: port.toString(),
|
||||
GOROOT: goRoot,
|
||||
GOPATH: goPath,
|
||||
GOCACHE: goCache,
|
||||
PATH: envPath,
|
||||
CGO_ENABLED: '0',
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue