8000 Set environment variables for go tools by bancek · Pull Request #932 · microsoft/vscode-go · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Set environment variables for go tools #932

Merged
merged 2 commits into from
May 1, 2017
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
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,11 @@
"default": null,
"description": "Flags to pass to `go test`. If null, then buildFlags will be used."
},
"go.toolsEnvVars": {
"type": "object",
"default": {},
"description": "Environment variables that will passed to the processes that run the Go tools (e.g. CGO_CFLAGS)"
},
"go.gocodeAutoBuild": {
"type": "boolean",
"default": true,
Expand Down Expand Up @@ -559,7 +564,7 @@
"default": 500,
"description": "The number of milliseconds to delay before execution. Resets with each keystroke."
}
},
},
"default": {
"enabled": false,
"delay": 500
Expand Down Expand Up @@ -624,7 +629,7 @@
"type": "boolean",
"default": true,
"description": "If true, adds command to run all tests in the current package to the editor context menu"
},
},
"generateTestForFunction": {
"type": "boolean",
"default": true,
Expand Down Expand Up @@ -701,7 +706,7 @@
{
"when": "editorTextFocus && config.go.editorContextMenuCommands.testPackage && resourceLangId == go",
"command": "go.test.package"
},
},
{
"when": "editorTextFocus && config.go.editorContextMenuCommands.generateTestForFunction && resourceLangId == go",
"command": "go.test.generate.function"
Expand Down
12 changes: 8 additions & 4 deletions src/goCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ export interface ICheckResult {
* @param toolName The name of the Go tool to run. If none is provided, the go runtime itself is used
* @param printUnexpectedOutput If true, then output that doesnt match expected format is printed to the output channel
*/
function runTool(args: string[], cwd: string, severity: string, useStdErr: boolean, toolName: string, printUnexpectedOutput?: boolean): Promise<ICheckResult[]> {
function runTool(args: string[], cwd: string, severity: string, useStdErr: boolean, toolName: string, env: any, printUnexpectedOutput?: boolean): Promise<ICheckResult[]> {
let goRuntimePath = getGoRuntimePath();
let cmd = toolName ? getBinPath(toolName) : goRuntimePath;
8000 return new Promise((resolve, reject) => {
cp.execFile(cmd, args, { cwd: cwd }, (err, stdout, stderr) => {
cp.execFile(cmd, args, { env: env, cwd: cwd }, (err, stdout, stderr) => {
try {
if (err && (<any>err).code === 'ENOENT') {
if (toolName) {
Expand Down Expand Up @@ -110,6 +110,7 @@ export function check(filename: string, goConfig: vscode.WorkspaceConfiguration)
outputChannel.clear();
let runningToolsPromises = [];
let cwd = path.dirname(filename);
let env = Object.assign({}, process.env, goConfig['toolsEnvVars']);
let goRuntimePath = getGoRuntimePath();

if (!goRuntimePath) {
Expand Down Expand Up @@ -176,6 +177,7 @@ export function check(filename: string, goConfig: vscode.WorkspaceConfiguration)
'error',
true,
null,
env,
true
).then(result => resolve(result), err => reject(err));
});
Expand Down Expand Up @@ -223,7 +225,8 @@ export function check(filename: string, goConfig: vscode.WorkspaceConfiguration)
cwd,
'warning',
false,
lintTool
lintTool,
env
));
}

Expand All @@ -234,7 +237,8 @@ export function check(filename: string, goConfig: vscode.WorkspaceConfiguration)
cwd,
'warning',
true,
null
null,
env
));
}

Expand Down
0