Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[code] Append go env variable 'GOCACHE' to go lsp spawn command. #44864

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions x-pack/legacy/plugins/code/server/lsp/go_launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand All @@ -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, {
Expand All @@ -109,6 +113,7 @@ export class GoServerLauncher extends AbstractLauncher {
CLIENT_PORT: port.toString(),
GOROOT: goRoot,
GOPATH: goPath,
GOCACHE: goCache,
PATH: envPath,
CGO_ENABLED: '0',
},
Expand Down