-
Notifications
You must be signed in to change notification settings - Fork 646
Make tools re-compiling warnings scoped by toolsGopath #1589
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,36 +66,45 @@ export function activate(ctx: vscode.ExtensionContext): void { | |
let useLangServer = vscode.workspace.getConfiguration('go')['useLanguageServer']; | ||
setGlobalState(ctx.globalState); | ||
|
||
updateGoPathGoRootFromConfig().then(() => { | ||
updateGoPathGoRootFromConfig().then(async () => { | ||
const updateToolsCmdText = 'Update tools'; | ||
const prevGoroot = ctx.globalState.get('goroot'); | ||
const currentGoroot = process.env['GOROOT']; | ||
if (prevGoroot !== currentGoroot && prevGoroot) { | ||
vscode.window.showInformationMessage('Your goroot is different than before, a few Go tools may need recompiling', updateToolsCmdText).then(selected => { | ||
interface GoInfo { | ||
goroot: string; | ||
version: string; | ||
} | ||
const toolsGoInfo: { [id: string]: GoInfo; } = ctx.globalState.get('toolsGoInfo') || {}; | ||
const toolsGopath = getToolsGopath() || getCurrentGoPath(); | ||
if (!toolsGoInfo[toolsGopath]) { | ||
toolsGoInfo[toolsGopath] = { goroot: null, version: null }; | ||
} | ||
const prevGoroot = toolsGoInfo[toolsGopath].goroot; | ||
vladbarosan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const currentGoroot: string = process.env['GOROOT']; | ||
if (prevGoroot && prevGoroot !== currentGoroot) { | ||
vscode.window.showInformationMessage(`Your current goroot (${currentGoroot}) is different than before (${prevGoroot}), a few Go tools may need recompiling`, updateToolsCmdText).then(selected => { | ||
if (selected === updateToolsCmdText) { | ||
installAllTools(true); | ||
} | ||
}); | ||
} else { | ||
getGoVersion().then(currentVersion => { | ||
if (currentVersion) { | ||
const prevVersion = ctx.globalState.get('goVersion'); | ||
const currVersionString = `${currentVersion.major}.${currentVersion.minor}`; | ||
|
||
if (prevVersion !== currVersionString) { | ||
if (prevVersion) { | ||
vscode.window.showInformationMessage('Your Go version is different than before, few Go tools may need re-compiling', updateToolsCmdText).then(selected => { | ||
if (selected === updateToolsCmdText) { | ||
installAllTools(true); | ||
} | ||
}); | ||
} | ||
ctx.globalState.update('goVersion', currVersionString); | ||
const currentVersion = await getGoVersion(); | ||
if (currentVersion) { | ||
const prevVersion = toolsGoInfo[toolsGopath].version; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When this update goes out, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yess, good catch There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we do, but just that is nested There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually i think its fine how it is ? because we show the warning only if prev version exists There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah! I missed the nested check. looks good |
||
const currVersionString = `${currentVersion.major}.${currentVersion.minor}`; | ||
|
||
if (prevVersion !== currVersionString) { | ||
if (prevVersion) { | ||
vscode.window.showInformationMessage('Your Go version is different than before, few Go tools may need re-compiling', updateToolsCmdText).then(selected => { | ||
if (selected === updateToolsCmdText) { | ||
installAllTools(true); | ||
} | ||
}); | ||
} | ||
toolsGoInfo[toolsGopath].version = currVersionString; | ||
} | ||
}); | ||
} | ||
} | ||
ctx.globalState.update('goroot', currentGoroot); | ||
toolsGoInfo[toolsGopath].goroot = currentGoroot; | ||
ctx.globalState.update('toolsGoInfo', toolsGoInfo); | ||
|
||
offerToInstallTools(); | ||
if (checkLanguageServer()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Go versions less than 1.8, it is possible that gopath will not be set, so
toolsGopath
here would be null or undefinedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ramya-rao-a is this still a concern given that 1.12 is out and we dont test for 1.8 anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only thing that comes to mind is the future when modules have taken over and
GOPATH
becomes obsolete. It's a larger issue though and I don't think it needs to hold up this PR.