package main import ( "fmt" "os" "strings" ) func init() { register(Check{ Seq: 30, ID: "3", Title: "Go code compiles and passes go fix, golangci-lint --fix, go vet, and strict lint", Run: func(ctx *ScanContext, rep *Reporter) { // Check 3: Go lint pipeline fmt.Println("=== Check 3: Go code compiles and passes go fix, golangci-lint --fix, go vet, and strict lint ===") goLintRoots := make([]string, 0, len(ctx.pluginTargets)) for _, target := range ctx.pluginTargets { goLintRoots = append(goLintRoots, target.root) } backendLintRoots := make([]string, 0, len(ctx.backendTargets)) for _, target := range ctx.backendTargets { backendLintRoots = append(backendLintRoots, target.root) } completedGoTargets, skippedGoTargets, goLintFailures, goLintErr := runStrictGoLint(ctx.repoRoot, backendLintRoots, goLintRoots) if goLintErr != nil { fmt.Printf(" ERROR: failed to run Go lint pipeline: %v\n", goLintErr) os.Exit(2) } for _, skipped := range skippedGoTargets { fmt.Printf(" SKIP: %s\n", skipped) } if len(goLintFailures) > 0 { fmt.Printf(" FAIL: %d Go module(s) failed the Go lint pipeline:\n", len(goLintFailures)) for _, failure := range goLintFailures { fmt.Printf(" [%s]\n", failure.target) if failure.output != "" { for line := range strings.SplitSeq(failure.output, "\n") { fmt.Printf(" %s\n", line) } } } rep.Fail() } else if len(completedGoTargets) > 0 { fmt.Printf(" OK: Go lint pipeline clean for %d module(s)\n", len(completedGoTargets)) for _, target := range completedGoTargets { fmt.Printf(" - %s\n", target) } } else { fmt.Println(" SKIP: no Go modules found") } fmt.Println() }, }) }