File: validate_go_mod.ps1

package info (click to toggle)
golang-github-azure-azure-sdk-for-go 68.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 556,256 kB
  • sloc: javascript: 196; sh: 96; makefile: 7
file content (35 lines) | stat: -rw-r--r-- 859 bytes parent folder | download | duplicates (3)
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
35
Param(
    [string] $serviceDir
)

. (Join-Path $PSScriptRoot .. common scripts common.ps1)

Push-Location sdk/$serviceDir

$goModFiles = Get-ChildItem -Path . -Filter go.mod -Recurse

if ($goModFiles.Length -eq 0) {
    Write-Host "Could not find a go.mod file in the directory $(Get-Location)"
    exit 1
}

$hasError = $false
foreach ($goMod in $goModFiles) {
    $mod = Get-GoModuleProperties ($goMod.Directory -replace ".*\/azure-sdk-for-go\/")
    if ($mod) {
        $name = $goMod.FullName
        $patternMatches = Get-Content $name | Select-String -Pattern "replace "
        if ($patternMatches.Length -ne 0) {
            Write-Host "Found a replace directive in go.mod file at $name"
            $hasError = $true
        } else {
            Write-Host "Valid go.mod file at $name"
        }
    }
}

Pop-Location

if ($hasError) {
    exit 1
}