forked from christianbumann/terraform-provider-azuredevops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlint-check-go.ps1
34 lines (28 loc) · 803 Bytes
/
lint-check-go.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
[CmdletBinding()]
param (
)
$script:PSDefaultParameterValues = @{
'*:Confirm' = $false
'*:ErrorAction' = 'Stop'
}
. (Join-Path -Path $PSScriptRoot -ChildPath 'commons.ps1' -Resolve)
echo "[INFO] Linting Go Files... If this fails, run 'golint ./... | grep -v 'vendor' ' to see errors"
Push-Location -Path $SOURCE_DIR
try {
go get -u golang.org/x/lint/golint 2>$null
if ($LASTEXITCODE) {
throw "Failed to install or update golint"
}
go list ./... `
| Select-String -NotMatch -SimpleMatch 'vendor' `
| ForEach-Object -Process {
$package = $_
golint.exe -set_exit_status $package
if ($LASTEXITCODE) {
Write-Error -Message "Linting failed for package: $package"
}
}
}
finally {
Pop-Location
}