Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #46 from pcmind/master
Browse files Browse the repository at this point in the history
Fix gopath bin location search and error in error line parsing in windows
  • Loading branch information
lukehoban committed Nov 20, 2015
2 parents b644015 + 821b545 commit bf61793
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/goCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ export function check(filename: string, buildOnSave = true, lintOnSave = true, v
var lines = stderr.toString().split('\n');
var ret: ICheckResult[] = [];
for(var i = 1; i < lines.length; i++) {
var match = /(.*):(\d+): (.*)/.exec(lines[i]);
var match = /([^:]*):(\d+)(:\d+)?: (.*)/.exec(lines[i]);
if(!match) continue;
var [_, file, lineStr, msg] = match;
var [_, file, lineStr, charStr, msg] = match;
var line = +lineStr;
ret.push({ file: path.resolve(cwd, file), line, msg, severity: "error" });
}
Expand Down
12 changes: 9 additions & 3 deletions src/goPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { showGoStatus, hideGoStatus } from './goStatus'
var binPathCache : { [bin: string]: string;} = {}

export function getBinPath(binname) {
binname = correctBinname(binname)
if(binPathCache[binname]) return binPathCache[binname];
var workspaces = getGOPATHWorkspaces();
var binpath: string;
Expand All @@ -27,6 +28,13 @@ export function getBinPath(binname) {
return path.join(process.env["GOPATH"], "bin", binname);
}

function correctBinname(binname) {
if (process.platform === 'win32')
return binname + ".exe";
else
return binname
}

function getGOPATHWorkspaces() {
var seperator : string;
switch(os.platform()) {
Expand Down Expand Up @@ -75,9 +83,7 @@ export function setupGoPathAndOfferToInstallTools() {
}
var keys = Object.keys(tools)
Promise.all(keys.map(tool => new Promise<string>((resolve, reject) => {
let toolPath = path.join(process.env["GOPATH"], 'bin', tool);
if (process.platform === 'win32')
toolPath = toolPath + ".exe";
let toolPath = getBinPath(tool);
fs.exists(toolPath, exists => {
resolve(exists ? null : tools[tool])
});
Expand Down

0 comments on commit bf61793

Please sign in to comment.