Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions _extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@
"tags": [
"experimental"
]
},
"typescript.native-preview.goMemLimit": {
"type": "string",
"description": "Set GOMEMLIMIT for the language server (e.g., '2048MiB', '4GiB'). See https://pkg.go.dev/runtime#hdr-Environment_Variables for more information.",
"pattern": "^[0-9]+(([KMGT]i)?B)?$",
"patternErrorMessage": "Must be a valid memory limit (e.g., '2048MiB', '4GiB').",
"tags": [
"experimental"
]
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions _extension/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,31 @@ export class Client {
const pprofDir = config.get<string>("pprofDir");
const pprofArgs = pprofDir ? ["--pprofDir", pprofDir] : [];

const goMemLimit = config.get<string>("goMemLimit");
const env = { ...process.env };
if (goMemLimit) {
// Keep this regex aligned with the pattern in package.json.
if (/^[0-9]+(([KMGT]i)?B)?$/.test(goMemLimit)) {
this.outputChannel.appendLine(`Setting GOMEMLIMIT=${goMemLimit}`);
env.GOMEMLIMIT = goMemLimit;
}
else {
this.outputChannel.error(`Invalid goMemLimit: ${goMemLimit}. Must be a valid memory limit (e.g., '2048MiB', '4GiB'). Not overriding GOMEMLIMIT.`);
}
}

const serverOptions: ServerOptions = {
run: {
command: this.exe.path,
args: ["--lsp", ...pprofArgs],
transport: TransportKind.stdio,
options: { env },
},
debug: {
command: this.exe.path,
args: ["--lsp", ...pprofArgs],
transport: TransportKind.stdio,
options: { env },
},
};

Expand Down