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

@@ -1,12 +0,0 @@
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build go1.23
//go:debug gotypesalias=1
package main
// Materialize aliases whenever the go toolchain version is after 1.23 (#69772).
// Remove this file after go.mod >= 1.23 (which implies gotypesalias=1).

View File

@@ -6,6 +6,7 @@ package main
import (
"context"
"errors"
"fmt"
"os"
@@ -23,11 +24,20 @@ func main() {
if err == nil {
err = cmd.Wait()
}
switch err := err.(type) {
case nil:
case interface{ ExitCode() int }:
os.Exit(err.ExitCode())
default:
if err != nil {
var e interface{ ExitCode() int }
if errors.As(err, &e) {
printErrorToStderr := true
if _, ok := err.(interface{ ExitCode() int }); ok {
// Avoid printing the error to stderr if the exit code error wasn't
// wrapped with another error providing context.
printErrorToStderr = false
}
if printErrorToStderr {
fmt.Fprintln(os.Stderr, err)
}
os.Exit(e.ExitCode())
}
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}

View File

@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build go1.18
// +build go1.18
package buildinfo

View File

@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build go1.18
// +build go1.18
package buildinfo

View File

@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build go1.18
// +build go1.18
package buildinfo

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)
}

View File

@@ -93,7 +93,7 @@ func callGraph(ctx context.Context, prog *ssa.Program, entries []*ssa.Function)
// - pointer designation * is skipped
// - full path prefix is skipped as well
func dbTypeFormat(t types.Type) string {
switch tt := t.(type) {
switch tt := types.Unalias(t).(type) {
case *types.Pointer:
return dbTypeFormat(tt.Elem())
case *types.Named:

View File

@@ -89,6 +89,16 @@ func (c *Cmd) Start() error {
// Wait waits for the command to exit. The command must have been started by
// Start.
//
// If the command fails to run or does not complete successfully, the returned
// error wraps an error implementing:
//
// interface {
// ExitCode() int
// }
//
// Callers can use errors.As to retrieve the exit code. Other errors may be
// returned for other problems (e.g. I/O issues).
//
// Wait releases any resources associated with the Cmd.
func (c *Cmd) Wait() error {
if c.done == nil {