Update go version

This commit is contained in:
dwrz
2026-08-21 10:23:37 +00:00
parent 78248a6145
commit c2e2d9ea02
466 changed files with 67766 additions and 2881 deletions

View File

@@ -11,7 +11,7 @@ import (
//lint:file-ignore ST1005 Ignore staticcheck message about error formatting
var (
// ErrVulnerabilitiesFound indicates that vulnerabilities were detected
// errVulnerabilitiesFound indicates that vulnerabilities were detected
// when running govulncheck. This returns exit status 3 when running
// without the -json flag.
errVulnerabilitiesFound = &exitCodeError{message: "vulnerabilities found", code: 3}
@@ -25,6 +25,18 @@ var (
// govulncheck and exit with status 2.
errUsage = &exitCodeError{message: "invalid usage", code: 2}
// errNoPatterns indicates that no package patterns were provided if the scan level is WantPackages.
errNoPatterns = &exitCodeError{
message: "no package patterns provided\n\nTo scan the current module, run: govulncheck ./...",
code: 2,
}
// errNoPackagesMatched indicates that the provided patterns matched no packages if scan level is WantPackages.
errNoPackagesMatched = &exitCodeError{
message: "no packages matched the provided patterns",
code: 2,
}
// errGoVersionMismatch is used to indicate that there is a mismatch between
// the Go version used to build govulncheck and the one currently on PATH.
errGoVersionMismatch = errors.New(`Loading packages failed, possibly due to a mismatch between the Go version

View File

@@ -25,6 +25,7 @@ type config struct {
test bool
show ShowFlag
format FormatFlag
version bool
env []string
}
@@ -72,6 +73,7 @@ Usage:
cfg.patterns = flags.Args()
if version {
cfg.show = append(cfg.show, "version")
cfg.version = true
}
cfg.ScanLevel = govulncheck.ScanLevel(scanFlag)
cfg.ScanMode = govulncheck.ScanMode(modeFlag)

View File

@@ -22,9 +22,8 @@ import (
"golang.org/x/vuln/internal/sarif"
)
// RunGovulncheck performs main govulncheck functionality and exits the
// program upon success with an appropriate exit status. Otherwise,
// returns an error.
// RunGovulncheck performs main govulncheck functionality.
// On failure, the returned error wraps an exit code error (see scan.Cmd.Wait).
func RunGovulncheck(ctx context.Context, env []string, r io.Reader, stdout io.Writer, stderr io.Writer, args []string) error {
cfg := &config{env: env}
if err := parseFlags(cfg, stderr, args); err != nil {
@@ -55,6 +54,12 @@ func RunGovulncheck(ctx context.Context, env []string, r io.Reader, stdout io.Wr
return err
}
if cfg.version {
// If the -version flag is passed, exit before doing anything else. This is different than
// passing -show which includes "version".
return nil
}
incTelemetryFlagCounters(cfg)
switch cfg.ScanMode {
@@ -104,7 +109,7 @@ func prepareConfig(ctx context.Context, cfg *config, client *client.Client) {
// this binary used from the build info.
func scannerVersion(cfg *config, bi *debug.BuildInfo) {
if bi.Path != "" {
cfg.ScannerName = path.Base(bi.Path)
cfg.ScannerName = strings.TrimSuffix(path.Base(bi.Path), ".test")
}
if bi.Main.Version != "" && bi.Main.Version != "(devel)" {
cfg.ScannerVersion = bi.Main.Version

View File

@@ -24,7 +24,7 @@ func runSource(ctx context.Context, handler govulncheck.Handler, cfg *config, cl
defer derrors.Wrap(&err, "govulncheck")
if cfg.ScanLevel.WantPackages() && len(cfg.patterns) == 0 {
return nil // don't throw an error here
return errNoPatterns
}
if !gomodExists(dir) {
return errNoGoMod
@@ -43,7 +43,7 @@ func runSource(ctx context.Context, handler govulncheck.Handler, cfg *config, cl
}
if cfg.ScanLevel.WantPackages() && len(graph.TopPkgs()) == 0 {
return nil // early exit
return errNoPackagesMatched
}
return vulncheck.Source(ctx, handler, &cfg.Config, client, graph)
}