2019-12-13 09:48:00 -05:00
|
|
|
################################################################################
|
|
|
|
|
## File: Install-Go.ps1
|
|
|
|
|
## Desc: Install Go
|
|
|
|
|
################################################################################
|
|
|
|
|
|
2020-06-19 13:47:55 +03:00
|
|
|
Import-Module -Name ImageHelpers -Force -DisableNameChecking
|
2019-12-13 09:48:00 -05:00
|
|
|
|
2020-06-19 13:47:55 +03:00
|
|
|
# Get Go content from toolset
|
|
|
|
|
$goTool = Get-ToolsetContent | Select-Object -ExpandProperty toolcache | Where-Object Name -eq "go"
|
2020-05-05 20:49:34 +03:00
|
|
|
|
2020-06-19 13:47:55 +03:00
|
|
|
$toolPath = Join-Path $env:AGENT_TOOLSDIRECTORY $goTool.name
|
|
|
|
|
foreach($goVersion in $goTool.versions)
|
2019-12-13 09:48:00 -05:00
|
|
|
{
|
2020-06-19 13:47:55 +03:00
|
|
|
if ($goVersion.Split(".").Length -lt 3) {
|
|
|
|
|
$goVersion += ".*"
|
2019-12-13 09:48:00 -05:00
|
|
|
}
|
2020-06-19 13:47:55 +03:00
|
|
|
$expectedVersionPath = Join-Path $toolPath $goVersion
|
|
|
|
|
$foundVersion = Get-Item $expectedVersionPath `
|
|
|
|
|
| Sort-Object -Property {[version]$_.name} -Descending `
|
|
|
|
|
| Select-Object -First 1
|
|
|
|
|
# Check for required architecture folder
|
|
|
|
|
$foundVersionArchPath = Join-Path $foundVersion $goTool.arch
|
|
|
|
|
$envName = "GOROOT_{0}_{1}_X64" -f $goVersion.split(".")
|
|
|
|
|
setx $envName "$foundVersionArchPath" /M
|
|
|
|
|
}
|