mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-04-04 05:37:38 +03:00
Update quic-go dependency to support go 1.20 (#2292)
This commit is contained in:
parent
5438eed2f4
commit
c3fd855831
296 changed files with 14851 additions and 2397 deletions
2
vendor/golang.org/x/mod/modfile/read.go
generated
vendored
2
vendor/golang.org/x/mod/modfile/read.go
generated
vendored
|
@ -494,7 +494,7 @@ func (in *input) endToken(kind tokenKind) {
|
|||
in.token.endPos = in.pos
|
||||
}
|
||||
|
||||
// peek returns the kind of the the next token returned by lex.
|
||||
// peek returns the kind of the next token returned by lex.
|
||||
func (in *input) peek() tokenKind {
|
||||
return in.token.kind
|
||||
}
|
||||
|
|
3
vendor/golang.org/x/mod/modfile/rule.go
generated
vendored
3
vendor/golang.org/x/mod/modfile/rule.go
generated
vendored
|
@ -513,6 +513,9 @@ func parseReplace(filename string, line *Line, verb string, args []string, fix V
|
|||
nv := ""
|
||||
if len(args) == arrow+2 {
|
||||
if !IsDirectoryPath(ns) {
|
||||
if strings.Contains(ns, "@") {
|
||||
return nil, errorf("replacement module must match format 'path version', not 'path@version'")
|
||||
}
|
||||
return nil, errorf("replacement module without version must be directory path (rooted or starting with ./ or ../)")
|
||||
}
|
||||
if filepath.Separator == '/' && strings.Contains(ns, `\`) {
|
||||
|
|
4
vendor/golang.org/x/mod/module/module.go
generated
vendored
4
vendor/golang.org/x/mod/module/module.go
generated
vendored
|
@ -96,13 +96,13 @@ package module
|
|||
// Changes to the semantics in this file require approval from rsc.
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"path"
|
||||
"sort"
|
||||
"strings"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
"errors"
|
||||
|
||||
"golang.org/x/mod/semver"
|
||||
)
|
||||
|
@ -258,7 +258,7 @@ func modPathOK(r rune) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// modPathOK reports whether r can appear in a package import path element.
|
||||
// importPathOK reports whether r can appear in a package import path element.
|
||||
//
|
||||
// Import paths are intermediate between module paths and file paths: we allow
|
||||
// disallow characters that would be confusing or ambiguous as arguments to
|
||||
|
|
2
vendor/golang.org/x/tools/go/analysis/diagnostic.go
generated
vendored
2
vendor/golang.org/x/tools/go/analysis/diagnostic.go
generated
vendored
|
@ -37,7 +37,7 @@ type Diagnostic struct {
|
|||
// declaration.
|
||||
type RelatedInformation struct {
|
||||
Pos token.Pos
|
||||
End token.Pos
|
||||
End token.Pos // optional
|
||||
Message string
|
||||
}
|
||||
|
||||
|
|
16
vendor/golang.org/x/tools/go/analysis/doc.go
generated
vendored
16
vendor/golang.org/x/tools/go/analysis/doc.go
generated
vendored
|
@ -177,14 +177,14 @@ Diagnostic is defined as:
|
|||
The optional Category field is a short identifier that classifies the
|
||||
kind of message when an analysis produces several kinds of diagnostic.
|
||||
|
||||
Many analyses want to associate diagnostics with a severity level.
|
||||
Because Diagnostic does not have a severity level field, an Analyzer's
|
||||
diagnostics effectively all have the same severity level. To separate which
|
||||
diagnostics are high severity and which are low severity, expose multiple
|
||||
Analyzers instead. Analyzers should also be separated when their
|
||||
diagnostics belong in different groups, or could be tagged differently
|
||||
before being shown to the end user. Analyzers should document their severity
|
||||
level to help downstream tools surface diagnostics properly.
|
||||
The Diagnostic struct does not have a field to indicate its severity
|
||||
because opinions about the relative importance of Analyzers and their
|
||||
diagnostics vary widely among users. The design of this framework does
|
||||
not hold each Analyzer responsible for identifying the severity of its
|
||||
diagnostics. Instead, we expect that drivers will allow the user to
|
||||
customize the filtering and prioritization of diagnostics based on the
|
||||
producing Analyzer and optional Category, according to the user's
|
||||
preferences.
|
||||
|
||||
Most Analyzers inspect typed Go syntax trees, but a few, such as asmdecl
|
||||
and buildtag, inspect the raw text of Go source files or even non-Go
|
||||
|
|
15
vendor/golang.org/x/tools/go/analysis/passes/assign/assign.go
generated
vendored
15
vendor/golang.org/x/tools/go/analysis/passes/assign/assign.go
generated
vendored
|
@ -12,6 +12,7 @@ import (
|
|||
"fmt"
|
||||
"go/ast"
|
||||
"go/token"
|
||||
"go/types"
|
||||
"reflect"
|
||||
|
||||
"golang.org/x/tools/go/analysis"
|
||||
|
@ -51,7 +52,8 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
|||
for i, lhs := range stmt.Lhs {
|
||||
rhs := stmt.Rhs[i]
|
||||
if analysisutil.HasSideEffects(pass.TypesInfo, lhs) ||
|
||||
analysisutil.HasSideEffects(pass.TypesInfo, rhs) {
|
||||
analysisutil.HasSideEffects(pass.TypesInfo, rhs) ||
|
||||
isMapIndex(pass.TypesInfo, lhs) {
|
||||
continue // expressions may not be equal
|
||||
}
|
||||
if reflect.TypeOf(lhs) != reflect.TypeOf(rhs) {
|
||||
|
@ -74,3 +76,14 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
|||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// isMapIndex returns true if e is a map index expression.
|
||||
func isMapIndex(info *types.Info, e ast.Expr) bool {
|
||||
if idx, ok := analysisutil.Unparen(e).(*ast.IndexExpr); ok {
|
||||
if typ := info.Types[idx.X].Type; typ != nil {
|
||||
_, ok := typ.Underlying().(*types.Map)
|
||||
return ok
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
2
vendor/golang.org/x/tools/go/analysis/passes/inspect/inspect.go
generated
vendored
2
vendor/golang.org/x/tools/go/analysis/passes/inspect/inspect.go
generated
vendored
|
@ -24,7 +24,7 @@
|
|||
// inspect.Preorder(nil, func(n ast.Node) {
|
||||
// ...
|
||||
// })
|
||||
// return nil
|
||||
// return nil, nil
|
||||
// }
|
||||
package inspect
|
||||
|
||||
|
|
249
vendor/golang.org/x/tools/go/analysis/passes/loopclosure/loopclosure.go
generated
vendored
249
vendor/golang.org/x/tools/go/analysis/passes/loopclosure/loopclosure.go
generated
vendored
|
@ -14,15 +14,20 @@ import (
|
|||
"golang.org/x/tools/go/analysis/passes/inspect"
|
||||
"golang.org/x/tools/go/ast/inspector"
|
||||
"golang.org/x/tools/go/types/typeutil"
|
||||
"golang.org/x/tools/internal/analysisinternal"
|
||||
)
|
||||
|
||||
const Doc = `check references to loop variables from within nested functions
|
||||
|
||||
This analyzer checks for references to loop variables from within a
|
||||
function literal inside the loop body. It checks only instances where
|
||||
the function literal is called in a defer or go statement that is the
|
||||
last statement in the loop body, as otherwise we would need whole
|
||||
program analysis.
|
||||
This analyzer checks for references to loop variables from within a function
|
||||
literal inside the loop body. It checks for patterns where access to a loop
|
||||
variable is known to escape the current loop iteration:
|
||||
1. a call to go or defer at the end of the loop body
|
||||
2. a call to golang.org/x/sync/errgroup.Group.Go at the end of the loop body
|
||||
|
||||
The analyzer only considers references in the last statement of the loop body
|
||||
as it is not deep enough to understand the effects of subsequent statements
|
||||
which might render the reference benign.
|
||||
|
||||
For example:
|
||||
|
||||
|
@ -34,6 +39,10 @@ For example:
|
|||
|
||||
See: https://golang.org/doc/go_faq.html#closures_and_goroutines`
|
||||
|
||||
// TODO(rfindley): enable support for checking parallel subtests, pending
|
||||
// investigation, adding:
|
||||
// 3. a call testing.T.Run where the subtest body invokes t.Parallel()
|
||||
|
||||
var Analyzer = &analysis.Analyzer{
|
||||
Name: "loopclosure",
|
||||
Doc: Doc,
|
||||
|
@ -50,10 +59,12 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
|||
}
|
||||
inspect.Preorder(nodeFilter, func(n ast.Node) {
|
||||
// Find the variables updated by the loop statement.
|
||||
var vars []*ast.Ident
|
||||
var vars []types.Object
|
||||
addVar := func(expr ast.Expr) {
|
||||
if id, ok := expr.(*ast.Ident); ok {
|
||||
vars = append(vars, id)
|
||||
if id, _ := expr.(*ast.Ident); id != nil {
|
||||
if obj := pass.TypesInfo.ObjectOf(id); obj != nil {
|
||||
vars = append(vars, obj)
|
||||
}
|
||||
}
|
||||
}
|
||||
var body *ast.BlockStmt
|
||||
|
@ -79,52 +90,79 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
|||
return
|
||||
}
|
||||
|
||||
// Inspect a go or defer statement
|
||||
// if it's the last one in the loop body.
|
||||
// (We give up if there are following statements,
|
||||
// because it's hard to prove go isn't followed by wait,
|
||||
// or defer by return.)
|
||||
if len(body.List) == 0 {
|
||||
return
|
||||
}
|
||||
// The function invoked in the last return statement.
|
||||
var fun ast.Expr
|
||||
switch s := body.List[len(body.List)-1].(type) {
|
||||
case *ast.GoStmt:
|
||||
fun = s.Call.Fun
|
||||
case *ast.DeferStmt:
|
||||
fun = s.Call.Fun
|
||||
case *ast.ExprStmt: // check for errgroup.Group.Go()
|
||||
if call, ok := s.X.(*ast.CallExpr); ok {
|
||||
fun = goInvokes(pass.TypesInfo, call)
|
||||
}
|
||||
}
|
||||
lit, ok := fun.(*ast.FuncLit)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
ast.Inspect(lit.Body, func(n ast.Node) bool {
|
||||
id, ok := n.(*ast.Ident)
|
||||
if !ok || id.Obj == nil {
|
||||
return true
|
||||
}
|
||||
if pass.TypesInfo.Types[id].Type == nil {
|
||||
// Not referring to a variable (e.g. struct field name)
|
||||
return true
|
||||
}
|
||||
for _, v := range vars {
|
||||
if v.Obj == id.Obj {
|
||||
pass.ReportRangef(id, "loop variable %s captured by func literal",
|
||||
id.Name)
|
||||
// Inspect statements to find function literals that may be run outside of
|
||||
// the current loop iteration.
|
||||
//
|
||||
// For go, defer, and errgroup.Group.Go, we ignore all but the last
|
||||
// statement, because it's hard to prove go isn't followed by wait, or
|
||||
// defer by return.
|
||||
//
|
||||
// We consider every t.Run statement in the loop body, because there is
|
||||
// no such commonly used mechanism for synchronizing parallel subtests.
|
||||
// It is of course theoretically possible to synchronize parallel subtests,
|
||||
// though such a pattern is likely to be exceedingly rare as it would be
|
||||
// fighting against the test runner.
|
||||
lastStmt := len(body.List) - 1
|
||||
for i, s := range body.List {
|
||||
var stmts []ast.Stmt // statements that must be checked for escaping references
|
||||
switch s := s.(type) {
|
||||
case *ast.GoStmt:
|
||||
if i == lastStmt {
|
||||
stmts = litStmts(s.Call.Fun)
|
||||
}
|
||||
|
||||
case *ast.DeferStmt:
|
||||
if i == lastStmt {
|
||||
stmts = litStmts(s.Call.Fun)
|
||||
}
|
||||
|
||||
case *ast.ExprStmt: // check for errgroup.Group.Go and testing.T.Run (with T.Parallel)
|
||||
if call, ok := s.X.(*ast.CallExpr); ok {
|
||||
if i == lastStmt {
|
||||
stmts = litStmts(goInvoke(pass.TypesInfo, call))
|
||||
}
|
||||
if stmts == nil && analysisinternal.LoopclosureParallelSubtests {
|
||||
stmts = parallelSubtest(pass.TypesInfo, call)
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
for _, stmt := range stmts {
|
||||
ast.Inspect(stmt, func(n ast.Node) bool {
|
||||
id, ok := n.(*ast.Ident)
|
||||
if !ok {
|
||||
return true
|
||||
}
|
||||
obj := pass.TypesInfo.Uses[id]
|
||||
if obj == nil {
|
||||
return true
|
||||
}
|
||||
for _, v := range vars {
|
||||
if v == obj {
|
||||
pass.ReportRangef(id, "loop variable %s captured by func literal", id.Name)
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// goInvokes returns a function expression that would be called asynchronously
|
||||
// litStmts returns all statements from the function body of a function
|
||||
// literal.
|
||||
//
|
||||
// If fun is not a function literal, it returns nil.
|
||||
func litStmts(fun ast.Expr) []ast.Stmt {
|
||||
lit, _ := fun.(*ast.FuncLit)
|
||||
if lit == nil {
|
||||
return nil
|
||||
}
|
||||
return lit.Body.List
|
||||
}
|
||||
|
||||
// goInvoke returns a function expression that would be called asynchronously
|
||||
// (but not awaited) in another goroutine as a consequence of the call.
|
||||
// For example, given the g.Go call below, it returns the function literal expression.
|
||||
//
|
||||
|
@ -133,33 +171,96 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
|||
// g.Go(func() error { ... })
|
||||
//
|
||||
// Currently only "golang.org/x/sync/errgroup.Group()" is considered.
|
||||
func goInvokes(info *types.Info, call *ast.CallExpr) ast.Expr {
|
||||
f := typeutil.StaticCallee(info, call)
|
||||
// Note: Currently only supports: golang.org/x/sync/errgroup.Go.
|
||||
if f == nil || f.Name() != "Go" {
|
||||
return nil
|
||||
}
|
||||
recv := f.Type().(*types.Signature).Recv()
|
||||
if recv == nil {
|
||||
return nil
|
||||
}
|
||||
rtype, ok := recv.Type().(*types.Pointer)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
named, ok := rtype.Elem().(*types.Named)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
if named.Obj().Name() != "Group" {
|
||||
return nil
|
||||
}
|
||||
pkg := f.Pkg()
|
||||
if pkg == nil {
|
||||
return nil
|
||||
}
|
||||
if pkg.Path() != "golang.org/x/sync/errgroup" {
|
||||
func goInvoke(info *types.Info, call *ast.CallExpr) ast.Expr {
|
||||
if !isMethodCall(info, call, "golang.org/x/sync/errgroup", "Group", "Go") {
|
||||
return nil
|
||||
}
|
||||
return call.Args[0]
|
||||
}
|
||||
|
||||
// parallelSubtest returns statements that would would be executed
|
||||
// asynchronously via the go test runner, as t.Run has been invoked with a
|
||||
// function literal that calls t.Parallel.
|
||||
//
|
||||
// In practice, users rely on the fact that statements before the call to
|
||||
// t.Parallel are synchronous. For example by declaring test := test inside the
|
||||
// function literal, but before the call to t.Parallel.
|
||||
//
|
||||
// Therefore, we only flag references that occur after the call to t.Parallel:
|
||||
//
|
||||
// import "testing"
|
||||
//
|
||||
// func TestFoo(t *testing.T) {
|
||||
// tests := []int{0, 1, 2}
|
||||
// for i, test := range tests {
|
||||
// t.Run("subtest", func(t *testing.T) {
|
||||
// println(i, test) // OK
|
||||
// t.Parallel()
|
||||
// println(i, test) // Not OK
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
func parallelSubtest(info *types.Info, call *ast.CallExpr) []ast.Stmt {
|
||||
if !isMethodCall(info, call, "testing", "T", "Run") {
|
||||
return nil
|
||||
}
|
||||
|
||||
lit, _ := call.Args[1].(*ast.FuncLit)
|
||||
if lit == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
for i, stmt := range lit.Body.List {
|
||||
exprStmt, ok := stmt.(*ast.ExprStmt)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if isMethodCall(info, exprStmt.X, "testing", "T", "Parallel") {
|
||||
return lit.Body.List[i+1:]
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// isMethodCall reports whether expr is a method call of
|
||||
// <pkgPath>.<typeName>.<method>.
|
||||
func isMethodCall(info *types.Info, expr ast.Expr, pkgPath, typeName, method string) bool {
|
||||
call, ok := expr.(*ast.CallExpr)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check that we are calling a method <method>
|
||||
f := typeutil.StaticCallee(info, call)
|
||||
if f == nil || f.Name() != method {
|
||||
return false
|
||||
}
|
||||
recv := f.Type().(*types.Signature).Recv()
|
||||
if recv == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check that the receiver is a <pkgPath>.<typeName> or
|
||||
// *<pkgPath>.<typeName>.
|
||||
rtype := recv.Type()
|
||||
if ptr, ok := recv.Type().(*types.Pointer); ok {
|
||||
rtype = ptr.Elem()
|
||||
}
|
||||
named, ok := rtype.(*types.Named)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
if named.Obj().Name() != typeName {
|
||||
return false
|
||||
}
|
||||
pkg := f.Pkg()
|
||||
if pkg == nil {
|
||||
return false
|
||||
}
|
||||
if pkg.Path() != pkgPath {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
22
vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go
generated
vendored
22
vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go
generated
vendored
|
@ -583,7 +583,6 @@ func checkPrintf(pass *analysis.Pass, kind Kind, call *ast.CallExpr, fn *types.F
|
|||
argNum := firstArg
|
||||
maxArgNum := firstArg
|
||||
anyIndex := false
|
||||
anyW := false
|
||||
for i, w := 0, 0; i < len(format); i += w {
|
||||
w = 1
|
||||
if format[i] != '%' {
|
||||
|
@ -606,11 +605,6 @@ func checkPrintf(pass *analysis.Pass, kind Kind, call *ast.CallExpr, fn *types.F
|
|||
pass.Reportf(call.Pos(), "%s does not support error-wrapping directive %%w", state.name)
|
||||
return
|
||||
}
|
||||
if anyW {
|
||||
pass.Reportf(call.Pos(), "%s call has more than one error-wrapping directive %%w", state.name)
|
||||
return
|
||||
}
|
||||
anyW = true
|
||||
}
|
||||
if len(state.argNums) > 0 {
|
||||
// Continue with the next sequential argument.
|
||||
|
@ -672,12 +666,13 @@ func (s *formatState) parseIndex() bool {
|
|||
s.scanNum()
|
||||
ok := true
|
||||
if s.nbytes == len(s.format) || s.nbytes == start || s.format[s.nbytes] != ']' {
|
||||
ok = false
|
||||
s.nbytes = strings.Index(s.format, "]")
|
||||
ok = false // syntax error is either missing "]" or invalid index.
|
||||
s.nbytes = strings.Index(s.format[start:], "]")
|
||||
if s.nbytes < 0 {
|
||||
s.pass.ReportRangef(s.call, "%s format %s is missing closing ]", s.name, s.format)
|
||||
return false
|
||||
}
|
||||
s.nbytes = s.nbytes + start
|
||||
}
|
||||
arg32, err := strconv.ParseInt(s.format[start:s.nbytes], 10, 32)
|
||||
if err != nil || !ok || arg32 <= 0 || arg32 > int64(len(s.call.Args)-s.firstArg) {
|
||||
|
@ -915,7 +910,7 @@ func okPrintfArg(pass *analysis.Pass, call *ast.CallExpr, state *formatState) (o
|
|||
if reason != "" {
|
||||
details = " (" + reason + ")"
|
||||
}
|
||||
pass.ReportRangef(call, "%s format %s has arg %s of wrong type %s%s", state.name, state.format, analysisutil.Format(pass.Fset, arg), typeString, details)
|
||||
pass.ReportRangef(call, "%s format %s has arg %s of wrong type %s%s, see also https://pkg.go.dev/fmt#hdr-Printing", state.name, state.format, analysisutil.Format(pass.Fset, arg), typeString, details)
|
||||
return false
|
||||
}
|
||||
if v.typ&argString != 0 && v.verb != 'T' && !bytes.Contains(state.flags, []byte{'#'}) {
|
||||
|
@ -950,11 +945,16 @@ func recursiveStringer(pass *analysis.Pass, e ast.Expr) (string, bool) {
|
|||
return "", false
|
||||
}
|
||||
|
||||
// inScope returns true if e is in the scope of f.
|
||||
inScope := func(e ast.Expr, f *types.Func) bool {
|
||||
return f.Scope() != nil && f.Scope().Contains(e.Pos())
|
||||
}
|
||||
|
||||
// Is the expression e within the body of that String or Error method?
|
||||
var method *types.Func
|
||||
if strOk && strMethod.Pkg() == pass.Pkg && strMethod.Scope().Contains(e.Pos()) {
|
||||
if strOk && strMethod.Pkg() == pass.Pkg && inScope(e, strMethod) {
|
||||
method = strMethod
|
||||
} else if errOk && errMethod.Pkg() == pass.Pkg && errMethod.Scope().Contains(e.Pos()) {
|
||||
} else if errOk && errMethod.Pkg() == pass.Pkg && inScope(e, errMethod) {
|
||||
method = errMethod
|
||||
} else {
|
||||
return "", false
|
||||
|
|
10
vendor/golang.org/x/tools/go/analysis/passes/printf/types.go
generated
vendored
10
vendor/golang.org/x/tools/go/analysis/passes/printf/types.go
generated
vendored
|
@ -299,13 +299,3 @@ func isConvertibleToString(typ types.Type) bool {
|
|||
|
||||
return false
|
||||
}
|
||||
|
||||
// hasBasicType reports whether x's type is a types.Basic with the given kind.
|
||||
func hasBasicType(pass *analysis.Pass, x ast.Expr, kind types.BasicKind) bool {
|
||||
t := pass.TypesInfo.Types[x].Type
|
||||
if t != nil {
|
||||
t = t.Underlying()
|
||||
}
|
||||
b, ok := t.(*types.Basic)
|
||||
return ok && b.Kind() == kind
|
||||
}
|
||||
|
|
9
vendor/golang.org/x/tools/go/analysis/passes/sortslice/analyzer.go
generated
vendored
9
vendor/golang.org/x/tools/go/analysis/passes/sortslice/analyzer.go
generated
vendored
|
@ -52,11 +52,20 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
|||
|
||||
arg := call.Args[0]
|
||||
typ := pass.TypesInfo.Types[arg].Type
|
||||
|
||||
if tuple, ok := typ.(*types.Tuple); ok {
|
||||
typ = tuple.At(0).Type() // special case for Slice(f(...))
|
||||
}
|
||||
|
||||
switch typ.Underlying().(type) {
|
||||
case *types.Slice, *types.Interface:
|
||||
return
|
||||
}
|
||||
|
||||
// Restore typ to the original type, we may unwrap the tuple above,
|
||||
// typ might not be the type of arg.
|
||||
typ = pass.TypesInfo.Types[arg].Type
|
||||
|
||||
var fixes []analysis.SuggestedFix
|
||||
switch v := typ.Underlying().(type) {
|
||||
case *types.Array:
|
||||
|
|
13
vendor/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go
generated
vendored
13
vendor/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go
generated
vendored
|
@ -134,6 +134,19 @@ func canonicalMethod(pass *analysis.Pass, id *ast.Ident) {
|
|||
}
|
||||
}
|
||||
|
||||
// Special case: Unwrap has two possible signatures.
|
||||
// Check for Unwrap() []error here.
|
||||
if id.Name == "Unwrap" {
|
||||
if args.Len() == 0 && results.Len() == 1 {
|
||||
t := typeString(results.At(0).Type())
|
||||
if t == "error" || t == "[]error" {
|
||||
return
|
||||
}
|
||||
}
|
||||
pass.ReportRangef(id, "method Unwrap() should have signature Unwrap() error or Unwrap() []error")
|
||||
return
|
||||
}
|
||||
|
||||
// Do the =s (if any) all match?
|
||||
if !matchParams(pass, expect.args, args, "=") || !matchParams(pass, expect.results, results, "=") {
|
||||
return
|
||||
|
|
3
vendor/golang.org/x/tools/go/ast/inspector/typeof.go
generated
vendored
3
vendor/golang.org/x/tools/go/ast/inspector/typeof.go
generated
vendored
|
@ -11,6 +11,7 @@ package inspector
|
|||
|
||||
import (
|
||||
"go/ast"
|
||||
"math"
|
||||
|
||||
"golang.org/x/tools/internal/typeparams"
|
||||
)
|
||||
|
@ -218,7 +219,7 @@ func typeOf(n ast.Node) uint64 {
|
|||
|
||||
func maskOf(nodes []ast.Node) uint64 {
|
||||
if nodes == nil {
|
||||
return 1<<64 - 1 // match all node types
|
||||
return math.MaxUint64 // match all node types
|
||||
}
|
||||
var mask uint64
|
||||
for _, n := range nodes {
|
||||
|
|
2
vendor/golang.org/x/tools/go/buildutil/util.go
generated
vendored
2
vendor/golang.org/x/tools/go/buildutil/util.go
generated
vendored
|
@ -80,7 +80,7 @@ func ContainingPackage(ctxt *build.Context, dir, filename string) (*build.Packag
|
|||
|
||||
// (go/build.Context defines these as methods, but does not export them.)
|
||||
|
||||
// hasSubdir calls ctxt.HasSubdir (if not nil) or else uses
|
||||
// HasSubdir calls ctxt.HasSubdir (if not nil) or else uses
|
||||
// the local file system to answer the question.
|
||||
func HasSubdir(ctxt *build.Context, root, dir string) (rel string, ok bool) {
|
||||
if f := ctxt.HasSubdir; f != nil {
|
||||
|
|
6
vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go
generated
vendored
6
vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go
generated
vendored
|
@ -87,7 +87,11 @@ func NewReader(r io.Reader) (io.Reader, error) {
|
|||
|
||||
// Read reads export data from in, decodes it, and returns type
|
||||
// information for the package.
|
||||
// The package name is specified by path.
|
||||
//
|
||||
// The package path (effectively its linker symbol prefix) is
|
||||
// specified by path, since unlike the package name, this information
|
||||
// may not be recorded in the export data.
|
||||
//
|
||||
// File position information is added to fset.
|
||||
//
|
||||
// Read may inspect and add to the imports map to ensure that references
|
||||
|
|
4
vendor/golang.org/x/tools/go/internal/gcimporter/iimport.go
generated
vendored
4
vendor/golang.org/x/tools/go/internal/gcimporter/iimport.go
generated
vendored
|
@ -51,6 +51,8 @@ const (
|
|||
iexportVersionPosCol = 1
|
||||
iexportVersionGo1_18 = 2
|
||||
iexportVersionGenerics = 2
|
||||
|
||||
iexportVersionCurrent = 2
|
||||
)
|
||||
|
||||
type ident struct {
|
||||
|
@ -96,7 +98,7 @@ func IImportBundle(fset *token.FileSet, imports map[string]*types.Package, data
|
|||
}
|
||||
|
||||
func iimportCommon(fset *token.FileSet, imports map[string]*types.Package, data []byte, bundle bool, path string) (pkgs []*types.Package, err error) {
|
||||
const currentVersion = 1
|
||||
const currentVersion = iexportVersionCurrent
|
||||
version := int64(-1)
|
||||
if !debug {
|
||||
defer func() {
|
||||
|
|
93
vendor/golang.org/x/tools/go/internal/gcimporter/ureader_yes.go
generated
vendored
93
vendor/golang.org/x/tools/go/internal/gcimporter/ureader_yes.go
generated
vendored
|
@ -36,6 +36,12 @@ type pkgReader struct {
|
|||
// laterFns holds functions that need to be invoked at the end of
|
||||
// import reading.
|
||||
laterFns []func()
|
||||
// laterFors is used in case of 'type A B' to ensure that B is processed before A.
|
||||
laterFors map[types.Type]int
|
||||
|
||||
// ifaces holds a list of constructed Interfaces, which need to have
|
||||
// Complete called after importing is done.
|
||||
ifaces []*types.Interface
|
||||
}
|
||||
|
||||
// later adds a function to be invoked at the end of import reading.
|
||||
|
@ -63,6 +69,15 @@ func UImportData(fset *token.FileSet, imports map[string]*types.Package, data []
|
|||
return
|
||||
}
|
||||
|
||||
// laterFor adds a function to be invoked at the end of import reading, and records the type that function is finishing.
|
||||
func (pr *pkgReader) laterFor(t types.Type, fn func()) {
|
||||
if pr.laterFors == nil {
|
||||
pr.laterFors = make(map[types.Type]int)
|
||||
}
|
||||
pr.laterFors[t] = len(pr.laterFns)
|
||||
pr.laterFns = append(pr.laterFns, fn)
|
||||
}
|
||||
|
||||
// readUnifiedPackage reads a package description from the given
|
||||
// unified IR export data decoder.
|
||||
func readUnifiedPackage(fset *token.FileSet, ctxt *types.Context, imports map[string]*types.Package, input pkgbits.PkgDecoder) *types.Package {
|
||||
|
@ -102,6 +117,10 @@ func readUnifiedPackage(fset *token.FileSet, ctxt *types.Context, imports map[st
|
|||
fn()
|
||||
}
|
||||
|
||||
for _, iface := range pr.ifaces {
|
||||
iface.Complete()
|
||||
}
|
||||
|
||||
pkg.MarkComplete()
|
||||
return pkg
|
||||
}
|
||||
|
@ -231,11 +250,35 @@ func (r *reader) doPkg() *types.Package {
|
|||
for i := range imports {
|
||||
imports[i] = r.pkg()
|
||||
}
|
||||
pkg.SetImports(imports)
|
||||
pkg.SetImports(flattenImports(imports))
|
||||
|
||||
return pkg
|
||||
}
|
||||
|
||||
// flattenImports returns the transitive closure of all imported
|
||||
// packages rooted from pkgs.
|
||||
func flattenImports(pkgs []*types.Package) []*types.Package {
|
||||
var res []*types.Package
|
||||
|
||||
seen := make(map[*types.Package]bool)
|
||||
var add func(pkg *types.Package)
|
||||
add = func(pkg *types.Package) {
|
||||
if seen[pkg] {
|
||||
return
|
||||
}
|
||||
seen[pkg] = true
|
||||
res = append(res, pkg)
|
||||
for _, imp := range pkg.Imports() {
|
||||
add(imp)
|
||||
}
|
||||
}
|
||||
|
||||
for _, pkg := range pkgs {
|
||||
add(pkg)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// @@@ Types
|
||||
|
||||
func (r *reader) typ() types.Type {
|
||||
|
@ -372,6 +415,16 @@ func (r *reader) interfaceType() *types.Interface {
|
|||
if implicit {
|
||||
iface.MarkImplicit()
|
||||
}
|
||||
|
||||
// We need to call iface.Complete(), but if there are any embedded
|
||||
// defined types, then we may not have set their underlying
|
||||
// interface type yet. So we need to defer calling Complete until
|
||||
// after we've called SetUnderlying everywhere.
|
||||
//
|
||||
// TODO(mdempsky): After CL 424876 lands, it should be safe to call
|
||||
// iface.Complete() immediately.
|
||||
r.p.ifaces = append(r.p.ifaces, iface)
|
||||
|
||||
return iface
|
||||
}
|
||||
|
||||
|
@ -477,13 +530,41 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types.Package, string) {
|
|||
|
||||
named.SetTypeParams(r.typeParamNames())
|
||||
|
||||
// TODO(mdempsky): Rewrite receiver types to underlying is an
|
||||
// Interface? The go/types importer does this (I think because
|
||||
// unit tests expected that), but cmd/compile doesn't care
|
||||
// about it, so maybe we can avoid worrying about that here.
|
||||
rhs := r.typ()
|
||||
r.p.later(func() {
|
||||
pk := r.p
|
||||
pk.laterFor(named, func() {
|
||||
// First be sure that the rhs is initialized, if it needs to be initialized.
|
||||
delete(pk.laterFors, named) // prevent cycles
|
||||
if i, ok := pk.laterFors[rhs]; ok {
|
||||
f := pk.laterFns[i]
|
||||
pk.laterFns[i] = func() {} // function is running now, so replace it with a no-op
|
||||
f() // initialize RHS
|
||||
}
|
||||
underlying := rhs.Underlying()
|
||||
|
||||
// If the underlying type is an interface, we need to
|
||||
// duplicate its methods so we can replace the receiver
|
||||
// parameter's type (#49906).
|
||||
if iface, ok := underlying.(*types.Interface); ok && iface.NumExplicitMethods() != 0 {
|
||||
methods := make([]*types.Func, iface.NumExplicitMethods())
|
||||
for i := range methods {
|
||||
fn := iface.ExplicitMethod(i)
|
||||
sig := fn.Type().(*types.Signature)
|
||||
|
||||
recv := types.NewVar(fn.Pos(), fn.Pkg(), "", named)
|
||||
methods[i] = types.NewFunc(fn.Pos(), fn.Pkg(), fn.Name(), types.NewSignature(recv, sig.Params(), sig.Results(), sig.Variadic()))
|
||||
}
|
||||
|
||||
embeds := make([]types.Type, iface.NumEmbeddeds())
|
||||
for i := range embeds {
|
||||
embeds[i] = iface.EmbeddedType(i)
|
||||
}
|
||||
|
||||
newIface := types.NewInterfaceType(methods, embeds)
|
||||
r.p.ifaces = append(r.p.ifaces, newIface)
|
||||
underlying = newIface
|
||||
}
|
||||
|
||||
named.SetUnderlying(underlying)
|
||||
})
|
||||
|
||||
|
|
5
vendor/golang.org/x/tools/go/internal/pkgbits/decoder.go
generated
vendored
5
vendor/golang.org/x/tools/go/internal/pkgbits/decoder.go
generated
vendored
|
@ -9,6 +9,7 @@ import (
|
|||
"fmt"
|
||||
"go/constant"
|
||||
"go/token"
|
||||
"io"
|
||||
"math/big"
|
||||
"os"
|
||||
"runtime"
|
||||
|
@ -94,7 +95,7 @@ func NewPkgDecoder(pkgPath, input string) PkgDecoder {
|
|||
pr.elemEnds = make([]uint32, pr.elemEndsEnds[len(pr.elemEndsEnds)-1])
|
||||
assert(binary.Read(r, binary.LittleEndian, pr.elemEnds[:]) == nil)
|
||||
|
||||
pos, err := r.Seek(0, os.SEEK_CUR)
|
||||
pos, err := r.Seek(0, io.SeekCurrent)
|
||||
assert(err == nil)
|
||||
|
||||
pr.elemData = input[pos:]
|
||||
|
@ -237,7 +238,7 @@ func (r *Decoder) Sync(mWant SyncMarker) {
|
|||
return
|
||||
}
|
||||
|
||||
pos, _ := r.Data.Seek(0, os.SEEK_CUR) // TODO(mdempsky): io.SeekCurrent after #44505 is resolved
|
||||
pos, _ := r.Data.Seek(0, io.SeekCurrent)
|
||||
mHave := SyncMarker(r.rawUvarint())
|
||||
writerPCs := make([]int, r.rawUvarint())
|
||||
for i := range writerPCs {
|
||||
|
|
18
vendor/golang.org/x/tools/go/internal/pkgbits/encoder.go
generated
vendored
18
vendor/golang.org/x/tools/go/internal/pkgbits/encoder.go
generated
vendored
|
@ -147,8 +147,9 @@ func (pw *PkgEncoder) NewEncoderRaw(k RelocKind) Encoder {
|
|||
type Encoder struct {
|
||||
p *PkgEncoder
|
||||
|
||||
Relocs []RelocEnt
|
||||
Data bytes.Buffer // accumulated element bitstream data
|
||||
Relocs []RelocEnt
|
||||
RelocMap map[RelocEnt]uint32
|
||||
Data bytes.Buffer // accumulated element bitstream data
|
||||
|
||||
encodingRelocHeader bool
|
||||
|
||||
|
@ -210,15 +211,18 @@ func (w *Encoder) rawVarint(x int64) {
|
|||
}
|
||||
|
||||
func (w *Encoder) rawReloc(r RelocKind, idx Index) int {
|
||||
// TODO(mdempsky): Use map for lookup; this takes quadratic time.
|
||||
for i, rEnt := range w.Relocs {
|
||||
if rEnt.Kind == r && rEnt.Idx == idx {
|
||||
return i
|
||||
e := RelocEnt{r, idx}
|
||||
if w.RelocMap != nil {
|
||||
if i, ok := w.RelocMap[e]; ok {
|
||||
return int(i)
|
||||
}
|
||||
} else {
|
||||
w.RelocMap = make(map[RelocEnt]uint32)
|
||||
}
|
||||
|
||||
i := len(w.Relocs)
|
||||
w.Relocs = append(w.Relocs, RelocEnt{r, idx})
|
||||
w.RelocMap[e] = uint32(i)
|
||||
w.Relocs = append(w.Relocs, e)
|
||||
return i
|
||||
}
|
||||
|
||||
|
|
4
vendor/golang.org/x/tools/go/internal/pkgbits/reloc.go
generated
vendored
4
vendor/golang.org/x/tools/go/internal/pkgbits/reloc.go
generated
vendored
|
@ -5,11 +5,11 @@
|
|||
package pkgbits
|
||||
|
||||
// A RelocKind indicates a particular section within a unified IR export.
|
||||
type RelocKind int
|
||||
type RelocKind int32
|
||||
|
||||
// An Index represents a bitstream element index within a particular
|
||||
// section.
|
||||
type Index int
|
||||
type Index int32
|
||||
|
||||
// A relocEnt (relocation entry) is an entry in an element's local
|
||||
// reference table.
|
||||
|
|
9
vendor/golang.org/x/tools/go/packages/golist.go
generated
vendored
9
vendor/golang.org/x/tools/go/packages/golist.go
generated
vendored
|
@ -60,6 +60,7 @@ func (r *responseDeduper) addAll(dr *driverResponse) {
|
|||
for _, root := range dr.Roots {
|
||||
r.addRoot(root)
|
||||
}
|
||||
r.dr.GoVersion = dr.GoVersion
|
||||
}
|
||||
|
||||
func (r *responseDeduper) addPackage(p *Package) {
|
||||
|
@ -454,11 +455,14 @@ func (state *golistState) createDriverResponse(words ...string) (*driverResponse
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
seen := make(map[string]*jsonPackage)
|
||||
pkgs := make(map[string]*Package)
|
||||
additionalErrors := make(map[string][]Error)
|
||||
// Decode the JSON and convert it to Package form.
|
||||
var response driverResponse
|
||||
response := &driverResponse{
|
||||
GoVersion: goVersion,
|
||||
}
|
||||
for dec := json.NewDecoder(buf); dec.More(); {
|
||||
p := new(jsonPackage)
|
||||
if err := dec.Decode(p); err != nil {
|
||||
|
@ -730,7 +734,7 @@ func (state *golistState) createDriverResponse(words ...string) (*driverResponse
|
|||
}
|
||||
sort.Slice(response.Packages, func(i, j int) bool { return response.Packages[i].ID < response.Packages[j].ID })
|
||||
|
||||
return &response, nil
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (state *golistState) shouldAddFilenameFromError(p *jsonPackage) bool {
|
||||
|
@ -756,6 +760,7 @@ func (state *golistState) shouldAddFilenameFromError(p *jsonPackage) bool {
|
|||
return len(p.Error.ImportStack) == 0 || p.Error.ImportStack[len(p.Error.ImportStack)-1] == p.ImportPath
|
||||
}
|
||||
|
||||
// getGoVersion returns the effective minor version of the go command.
|
||||
func (state *golistState) getGoVersion() (int, error) {
|
||||
state.goVersionOnce.Do(func() {
|
||||
state.goVersion, state.goVersionError = gocommand.GoVersion(state.ctx, state.cfgInvocation(), state.cfg.gocmdRunner)
|
||||
|
|
42
vendor/golang.org/x/tools/go/packages/packages.go
generated
vendored
42
vendor/golang.org/x/tools/go/packages/packages.go
generated
vendored
|
@ -19,6 +19,7 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -233,6 +234,11 @@ type driverResponse struct {
|
|||
// Imports will be connected and then type and syntax information added in a
|
||||
// later pass (see refine).
|
||||
Packages []*Package
|
||||
|
||||
// GoVersion is the minor version number used by the driver
|
||||
// (e.g. the go command on the PATH) when selecting .go files.
|
||||
// Zero means unknown.
|
||||
GoVersion int
|
||||
}
|
||||
|
||||
// Load loads and returns the Go packages named by the given patterns.
|
||||
|
@ -256,7 +262,7 @@ func Load(cfg *Config, patterns ...string) ([]*Package, error) {
|
|||
return nil, err
|
||||
}
|
||||
l.sizes = response.Sizes
|
||||
return l.refine(response.Roots, response.Packages...)
|
||||
return l.refine(response)
|
||||
}
|
||||
|
||||
// defaultDriver is a driver that implements go/packages' fallback behavior.
|
||||
|
@ -532,6 +538,7 @@ type loaderPackage struct {
|
|||
needsrc bool // load from source (Mode >= LoadTypes)
|
||||
needtypes bool // type information is either requested or depended on
|
||||
initial bool // package was matched by a pattern
|
||||
goVersion int // minor version number of go command on PATH
|
||||
}
|
||||
|
||||
// loader holds the working state of a single call to load.
|
||||
|
@ -618,7 +625,8 @@ func newLoader(cfg *Config) *loader {
|
|||
|
||||
// refine connects the supplied packages into a graph and then adds type and
|
||||
// and syntax information as requested by the LoadMode.
|
||||
func (ld *loader) refine(roots []string, list ...*Package) ([]*Package, error) {
|
||||
func (ld *loader) refine(response *driverResponse) ([]*Package, error) {
|
||||
roots := response.Roots
|
||||
rootMap := make(map[string]int, len(roots))
|
||||
for i, root := range roots {
|
||||
rootMap[root] = i
|
||||
|
@ -626,7 +634,7 @@ func (ld *loader) refine(roots []string, list ...*Package) ([]*Package, error) {
|
|||
ld.pkgs = make(map[string]*loaderPackage)
|
||||
// first pass, fixup and build the map and roots
|
||||
var initial = make([]*loaderPackage, len(roots))
|
||||
for _, pkg := range list {
|
||||
for _, pkg := range response.Packages {
|
||||
rootIndex := -1
|
||||
if i, found := rootMap[pkg.ID]; found {
|
||||
rootIndex = i
|
||||
|
@ -648,6 +656,7 @@ func (ld *loader) refine(roots []string, list ...*Package) ([]*Package, error) {
|
|||
Package: pkg,
|
||||
needtypes: needtypes,
|
||||
needsrc: needsrc,
|
||||
goVersion: response.GoVersion,
|
||||
}
|
||||
ld.pkgs[lpkg.ID] = lpkg
|
||||
if rootIndex >= 0 {
|
||||
|
@ -923,6 +932,33 @@ func (ld *loader) loadPackage(lpkg *loaderPackage) {
|
|||
lpkg.Errors = append(lpkg.Errors, errs...)
|
||||
}
|
||||
|
||||
// If the go command on the PATH is newer than the runtime,
|
||||
// then the go/{scanner,ast,parser,types} packages from the
|
||||
// standard library may be unable to process the files
|
||||
// selected by go list.
|
||||
//
|
||||
// There is currently no way to downgrade the effective
|
||||
// version of the go command (see issue 52078), so we proceed
|
||||
// with the newer go command but, in case of parse or type
|
||||
// errors, we emit an additional diagnostic.
|
||||
//
|
||||
// See:
|
||||
// - golang.org/issue/52078 (flag to set release tags)
|
||||
// - golang.org/issue/50825 (gopls legacy version support)
|
||||
// - golang.org/issue/55883 (go/packages confusing error)
|
||||
var runtimeVersion int
|
||||
if _, err := fmt.Sscanf(runtime.Version(), "go1.%d", &runtimeVersion); err == nil && runtimeVersion < lpkg.goVersion {
|
||||
defer func() {
|
||||
if len(lpkg.Errors) > 0 {
|
||||
appendError(Error{
|
||||
Pos: "-",
|
||||
Msg: fmt.Sprintf("This application uses version go1.%d of the source-processing packages but runs version go1.%d of 'go list'. It may fail to process source files that rely on newer language features. If so, rebuild the application using a newer version of Go.", runtimeVersion, lpkg.goVersion),
|
||||
Kind: UnknownError,
|
||||
})
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if ld.Config.Mode&NeedTypes != 0 && len(lpkg.CompiledGoFiles) == 0 && lpkg.ExportFile != "" {
|
||||
// The config requested loading sources and types, but sources are missing.
|
||||
// Add an error to the package and fall back to loading from export data.
|
||||
|
|
3
vendor/golang.org/x/tools/go/ssa/builder.go
generated
vendored
3
vendor/golang.org/x/tools/go/ssa/builder.go
generated
vendored
|
@ -2461,6 +2461,9 @@ func (p *Package) build() {
|
|||
}
|
||||
|
||||
// Initialize package-level vars in correct order.
|
||||
if len(p.info.InitOrder) > 0 && len(p.files) == 0 {
|
||||
panic("no source files provided for package. cannot initialize globals")
|
||||
}
|
||||
for _, varinit := range p.info.InitOrder {
|
||||
if init.Prog.mode&LogSource != 0 {
|
||||
fmt.Fprintf(os.Stderr, "build global initializer %v @ %s\n",
|
||||
|
|
2
vendor/golang.org/x/tools/go/ssa/dom.go
generated
vendored
2
vendor/golang.org/x/tools/go/ssa/dom.go
generated
vendored
|
@ -303,7 +303,7 @@ func sanityCheckDomTree(f *Function) {
|
|||
|
||||
// Printing functions ----------------------------------------
|
||||
|
||||
// printDomTree prints the dominator tree as text, using indentation.
|
||||
// printDomTreeText prints the dominator tree as text, using indentation.
|
||||
func printDomTreeText(buf *bytes.Buffer, v *BasicBlock, indent int) {
|
||||
fmt.Fprintf(buf, "%*s%s\n", 4*indent, "", v)
|
||||
for _, child := range v.dom.children {
|
||||
|
|
4
vendor/golang.org/x/tools/go/ssa/ssautil/load.go
generated
vendored
4
vendor/golang.org/x/tools/go/ssa/ssautil/load.go
generated
vendored
|
@ -77,10 +77,12 @@ func doPackages(initial []*packages.Package, mode ssa.BuilderMode, deps bool) (*
|
|||
packages.Visit(initial, nil, func(p *packages.Package) {
|
||||
if p.Types != nil && !p.IllTyped {
|
||||
var files []*ast.File
|
||||
var info *types.Info
|
||||
if deps || isInitial[p] {
|
||||
files = p.Syntax
|
||||
info = p.TypesInfo
|
||||
}
|
||||
ssamap[p] = prog.CreatePackage(p.Types, files, p.TypesInfo, true)
|
||||
ssamap[p] = prog.CreatePackage(p.Types, files, info, true)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
49
vendor/golang.org/x/tools/internal/analysisinternal/analysis.go
generated
vendored
49
vendor/golang.org/x/tools/internal/analysisinternal/analysis.go
generated
vendored
|
@ -14,9 +14,14 @@ import (
|
|||
"strconv"
|
||||
)
|
||||
|
||||
// Flag to gate diagnostics for fuzz tests in 1.18.
|
||||
// DiagnoseFuzzTests controls whether the 'tests' analyzer diagnoses fuzz tests
|
||||
// in Go 1.18+.
|
||||
var DiagnoseFuzzTests bool = false
|
||||
|
||||
// LoopclosureParallelSubtests controls whether the 'loopclosure' analyzer
|
||||
// diagnoses loop variables references in parallel subtests.
|
||||
var LoopclosureParallelSubtests = false
|
||||
|
||||
var (
|
||||
GetTypeErrors func(p interface{}) []types.Error
|
||||
SetTypeErrors func(p interface{}, errors []types.Error)
|
||||
|
@ -78,6 +83,9 @@ func IsZeroValue(expr ast.Expr) bool {
|
|||
}
|
||||
}
|
||||
|
||||
// TypeExpr returns syntax for the specified type. References to
|
||||
// named types from packages other than pkg are qualified by an appropriate
|
||||
// package name, as defined by the import environment of file.
|
||||
func TypeExpr(f *ast.File, pkg *types.Package, typ types.Type) ast.Expr {
|
||||
switch t := typ.(type) {
|
||||
case *types.Basic:
|
||||
|
@ -307,19 +315,21 @@ func WalkASTWithParent(n ast.Node, f func(n ast.Node, parent ast.Node) bool) {
|
|||
})
|
||||
}
|
||||
|
||||
// FindMatchingIdents finds all identifiers in 'node' that match any of the given types.
|
||||
// MatchingIdents finds the names of all identifiers in 'node' that match any of the given types.
|
||||
// 'pos' represents the position at which the identifiers may be inserted. 'pos' must be within
|
||||
// the scope of each of identifier we select. Otherwise, we will insert a variable at 'pos' that
|
||||
// is unrecognized.
|
||||
func FindMatchingIdents(typs []types.Type, node ast.Node, pos token.Pos, info *types.Info, pkg *types.Package) map[types.Type][]*ast.Ident {
|
||||
matches := map[types.Type][]*ast.Ident{}
|
||||
func MatchingIdents(typs []types.Type, node ast.Node, pos token.Pos, info *types.Info, pkg *types.Package) map[types.Type][]string {
|
||||
|
||||
// Initialize matches to contain the variable types we are searching for.
|
||||
matches := make(map[types.Type][]string)
|
||||
for _, typ := range typs {
|
||||
if typ == nil {
|
||||
continue
|
||||
continue // TODO(adonovan): is this reachable?
|
||||
}
|
||||
matches[typ] = []*ast.Ident{}
|
||||
matches[typ] = nil // create entry
|
||||
}
|
||||
|
||||
seen := map[types.Object]struct{}{}
|
||||
ast.Inspect(node, func(n ast.Node) bool {
|
||||
if n == nil {
|
||||
|
@ -331,8 +341,7 @@ func FindMatchingIdents(typs []types.Type, node ast.Node, pos token.Pos, info *t
|
|||
//
|
||||
// x := fakeStruct{f0: x}
|
||||
//
|
||||
assignment, ok := n.(*ast.AssignStmt)
|
||||
if ok && pos > assignment.Pos() && pos <= assignment.End() {
|
||||
if assign, ok := n.(*ast.AssignStmt); ok && pos > assign.Pos() && pos <= assign.End() {
|
||||
return false
|
||||
}
|
||||
if n.End() > pos {
|
||||
|
@ -365,17 +374,17 @@ func FindMatchingIdents(typs []types.Type, node ast.Node, pos token.Pos, info *t
|
|||
return true
|
||||
}
|
||||
// The object must match one of the types that we are searching for.
|
||||
if idents, ok := matches[obj.Type()]; ok {
|
||||
matches[obj.Type()] = append(idents, ast.NewIdent(ident.Name))
|
||||
}
|
||||
// If the object type does not exactly match any of the target types, greedily
|
||||
// find the first target type that the object type can satisfy.
|
||||
for typ := range matches {
|
||||
if obj.Type() == typ {
|
||||
continue
|
||||
}
|
||||
if equivalentTypes(obj.Type(), typ) {
|
||||
matches[typ] = append(matches[typ], ast.NewIdent(ident.Name))
|
||||
// TODO(adonovan): opt: use typeutil.Map?
|
||||
if names, ok := matches[obj.Type()]; ok {
|
||||
matches[obj.Type()] = append(names, ident.Name)
|
||||
} else {
|
||||
// If the object type does not exactly match
|
||||
// any of the target types, greedily find the first
|
||||
// target type that the object type can satisfy.
|
||||
for typ := range matches {
|
||||
if equivalentTypes(obj.Type(), typ) {
|
||||
matches[typ] = append(matches[typ], ident.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
@ -384,7 +393,7 @@ func FindMatchingIdents(typs []types.Type, node ast.Node, pos token.Pos, info *t
|
|||
}
|
||||
|
||||
func equivalentTypes(want, got types.Type) bool {
|
||||
if want == got || types.Identical(want, got) {
|
||||
if types.Identical(want, got) {
|
||||
return true
|
||||
}
|
||||
// Code segment to help check for untyped equality from (golang/go#32146).
|
||||
|
|
119
vendor/golang.org/x/tools/internal/fastwalk/fastwalk_darwin.go
generated
vendored
Normal file
119
vendor/golang.org/x/tools/internal/fastwalk/fastwalk_darwin.go
generated
vendored
Normal file
|
@ -0,0 +1,119 @@
|
|||
// Copyright 2022 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 darwin && cgo
|
||||
// +build darwin,cgo
|
||||
|
||||
package fastwalk
|
||||
|
||||
/*
|
||||
#include <dirent.h>
|
||||
|
||||
// fastwalk_readdir_r wraps readdir_r so that we don't have to pass a dirent**
|
||||
// result pointer which triggers CGO's "Go pointer to Go pointer" check unless
|
||||
// we allocat the result dirent* with malloc.
|
||||
//
|
||||
// fastwalk_readdir_r returns 0 on success, -1 upon reaching the end of the
|
||||
// directory, or a positive error number to indicate failure.
|
||||
static int fastwalk_readdir_r(DIR *fd, struct dirent *entry) {
|
||||
struct dirent *result;
|
||||
int ret = readdir_r(fd, entry, &result);
|
||||
if (ret == 0 && result == NULL) {
|
||||
ret = -1; // EOF
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func readDir(dirName string, fn func(dirName, entName string, typ os.FileMode) error) error {
|
||||
fd, err := openDir(dirName)
|
||||
if err != nil {
|
||||
return &os.PathError{Op: "opendir", Path: dirName, Err: err}
|
||||
}
|
||||
defer C.closedir(fd)
|
||||
|
||||
skipFiles := false
|
||||
var dirent syscall.Dirent
|
||||
for {
|
||||
ret := int(C.fastwalk_readdir_r(fd, (*C.struct_dirent)(unsafe.Pointer(&dirent))))
|
||||
if ret != 0 {
|
||||
if ret == -1 {
|
||||
break // EOF
|
||||
}
|
||||
if ret == int(syscall.EINTR) {
|
||||
continue
|
||||
}
|
||||
return &os.PathError{Op: "readdir", Path: dirName, Err: syscall.Errno(ret)}
|
||||
}
|
||||
if dirent.Ino == 0 {
|
||||
continue
|
||||
}
|
||||
typ := dtToType(dirent.Type)
|
||||
if skipFiles && typ.IsRegular() {
|
||||
continue
|
||||
}
|
||||
name := (*[len(syscall.Dirent{}.Name)]byte)(unsafe.Pointer(&dirent.Name))[:]
|
||||
name = name[:dirent.Namlen]
|
||||
for i, c := range name {
|
||||
if c == 0 {
|
||||
name = name[:i]
|
||||
break
|
||||
}
|
||||
}
|
||||
// Check for useless names before allocating a string.
|
||||
if string(name) == "." || string(name) == ".." {
|
||||
continue
|
||||
}
|
||||
if err := fn(dirName, string(name), typ); err != nil {
|
||||
if err != ErrSkipFiles {
|
||||
return err
|
||||
}
|
||||
skipFiles = true
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func dtToType(typ uint8) os.FileMode {
|
||||
switch typ {
|
||||
case syscall.DT_BLK:
|
||||
return os.ModeDevice
|
||||
case syscall.DT_CHR:
|
||||
return os.ModeDevice | os.ModeCharDevice
|
||||
case syscall.DT_DIR:
|
||||
return os.ModeDir
|
||||
case syscall.DT_FIFO:
|
||||
return os.ModeNamedPipe
|
||||
case syscall.DT_LNK:
|
||||
return os.ModeSymlink
|
||||
case syscall.DT_REG:
|
||||
return 0
|
||||
case syscall.DT_SOCK:
|
||||
return os.ModeSocket
|
||||
}
|
||||
return ^os.FileMode(0)
|
||||
}
|
||||
|
||||
// openDir wraps opendir(3) and handles any EINTR errors. The returned *DIR
|
||||
// needs to be closed with closedir(3).
|
||||
func openDir(path string) (*C.DIR, error) {
|
||||
name, err := syscall.BytePtrFromString(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for {
|
||||
fd, err := C.opendir((*C.char)(unsafe.Pointer(name)))
|
||||
if err != syscall.EINTR {
|
||||
return fd, err
|
||||
}
|
||||
}
|
||||
}
|
6
vendor/golang.org/x/tools/internal/fastwalk/fastwalk_dirent_ino.go
generated
vendored
6
vendor/golang.org/x/tools/internal/fastwalk/fastwalk_dirent_ino.go
generated
vendored
|
@ -2,8 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build (linux || darwin) && !appengine
|
||||
// +build linux darwin
|
||||
//go:build (linux || (darwin && !cgo)) && !appengine
|
||||
// +build linux darwin,!cgo
|
||||
// +build !appengine
|
||||
|
||||
package fastwalk
|
||||
|
@ -11,5 +11,5 @@ package fastwalk
|
|||
import "syscall"
|
||||
|
||||
func direntInode(dirent *syscall.Dirent) uint64 {
|
||||
return uint64(dirent.Ino)
|
||||
return dirent.Ino
|
||||
}
|
||||
|
|
4
vendor/golang.org/x/tools/internal/fastwalk/fastwalk_dirent_namlen_bsd.go
generated
vendored
4
vendor/golang.org/x/tools/internal/fastwalk/fastwalk_dirent_namlen_bsd.go
generated
vendored
|
@ -2,8 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build darwin || freebsd || openbsd || netbsd
|
||||
// +build darwin freebsd openbsd netbsd
|
||||
//go:build (darwin && !cgo) || freebsd || openbsd || netbsd
|
||||
// +build darwin,!cgo freebsd openbsd netbsd
|
||||
|
||||
package fastwalk
|
||||
|
||||
|
|
4
vendor/golang.org/x/tools/internal/fastwalk/fastwalk_unix.go
generated
vendored
4
vendor/golang.org/x/tools/internal/fastwalk/fastwalk_unix.go
generated
vendored
|
@ -2,8 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build (linux || darwin || freebsd || openbsd || netbsd) && !appengine
|
||||
// +build linux darwin freebsd openbsd netbsd
|
||||
//go:build (linux || freebsd || openbsd || netbsd || (darwin && !cgo)) && !appengine
|
||||
// +build linux freebsd openbsd netbsd darwin,!cgo
|
||||
// +build !appengine
|
||||
|
||||
package fastwalk
|
||||
|
|
83
vendor/golang.org/x/tools/internal/gocommand/invoke.go
generated
vendored
83
vendor/golang.org/x/tools/internal/gocommand/invoke.go
generated
vendored
|
@ -10,8 +10,10 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -232,6 +234,12 @@ func (i *Invocation) run(ctx context.Context, stdout, stderr io.Writer) error {
|
|||
return runCmdContext(ctx, cmd)
|
||||
}
|
||||
|
||||
// DebugHangingGoCommands may be set by tests to enable additional
|
||||
// instrumentation (including panics) for debugging hanging Go commands.
|
||||
//
|
||||
// See golang/go#54461 for details.
|
||||
var DebugHangingGoCommands = false
|
||||
|
||||
// runCmdContext is like exec.CommandContext except it sends os.Interrupt
|
||||
// before os.Kill.
|
||||
func runCmdContext(ctx context.Context, cmd *exec.Cmd) error {
|
||||
|
@ -243,11 +251,24 @@ func runCmdContext(ctx context.Context, cmd *exec.Cmd) error {
|
|||
resChan <- cmd.Wait()
|
||||
}()
|
||||
|
||||
select {
|
||||
case err := <-resChan:
|
||||
return err
|
||||
case <-ctx.Done():
|
||||
// If we're interested in debugging hanging Go commands, stop waiting after a
|
||||
// minute and panic with interesting information.
|
||||
if DebugHangingGoCommands {
|
||||
select {
|
||||
case err := <-resChan:
|
||||
return err
|
||||
case <-time.After(1 * time.Minute):
|
||||
HandleHangingGoCommand(cmd.Process)
|
||||
case <-ctx.Done():
|
||||
}
|
||||
} else {
|
||||
select {
|
||||
case err := <-resChan:
|
||||
return err
|
||||
case <-ctx.Done():
|
||||
}
|
||||
}
|
||||
|
||||
// Cancelled. Interrupt and see if it ends voluntarily.
|
||||
cmd.Process.Signal(os.Interrupt)
|
||||
select {
|
||||
|
@ -255,11 +276,63 @@ func runCmdContext(ctx context.Context, cmd *exec.Cmd) error {
|
|||
return err
|
||||
case <-time.After(time.Second):
|
||||
}
|
||||
|
||||
// Didn't shut down in response to interrupt. Kill it hard.
|
||||
cmd.Process.Kill()
|
||||
// TODO(rfindley): per advice from bcmills@, it may be better to send SIGQUIT
|
||||
// on certain platforms, such as unix.
|
||||
if err := cmd.Process.Kill(); err != nil && DebugHangingGoCommands {
|
||||
// Don't panic here as this reliably fails on windows with EINVAL.
|
||||
log.Printf("error killing the Go command: %v", err)
|
||||
}
|
||||
|
||||
// See above: don't wait indefinitely if we're debugging hanging Go commands.
|
||||
if DebugHangingGoCommands {
|
||||
select {
|
||||
case err := <-resChan:
|
||||
return err
|
||||
case <-time.After(10 * time.Second): // a shorter wait as resChan should return quickly following Kill
|
||||
HandleHangingGoCommand(cmd.Process)
|
||||
}
|
||||
}
|
||||
return <-resChan
|
||||
}
|
||||
|
||||
func HandleHangingGoCommand(proc *os.Process) {
|
||||
switch runtime.GOOS {
|
||||
case "linux", "darwin", "freebsd", "netbsd":
|
||||
fmt.Fprintln(os.Stderr, `DETECTED A HANGING GO COMMAND
|
||||
|
||||
The gopls test runner has detected a hanging go command. In order to debug
|
||||
this, the output of ps and lsof/fstat is printed below.
|
||||
|
||||
See golang/go#54461 for more details.`)
|
||||
|
||||
fmt.Fprintln(os.Stderr, "\nps axo ppid,pid,command:")
|
||||
fmt.Fprintln(os.Stderr, "-------------------------")
|
||||
psCmd := exec.Command("ps", "axo", "ppid,pid,command")
|
||||
psCmd.Stdout = os.Stderr
|
||||
psCmd.Stderr = os.Stderr
|
||||
if err := psCmd.Run(); err != nil {
|
||||
panic(fmt.Sprintf("running ps: %v", err))
|
||||
}
|
||||
|
||||
listFiles := "lsof"
|
||||
if runtime.GOOS == "freebsd" || runtime.GOOS == "netbsd" {
|
||||
listFiles = "fstat"
|
||||
}
|
||||
|
||||
fmt.Fprintln(os.Stderr, "\n"+listFiles+":")
|
||||
fmt.Fprintln(os.Stderr, "-----")
|
||||
listFilesCmd := exec.Command(listFiles)
|
||||
listFilesCmd.Stdout = os.Stderr
|
||||
listFilesCmd.Stderr = os.Stderr
|
||||
if err := listFilesCmd.Run(); err != nil {
|
||||
panic(fmt.Sprintf("running %s: %v", listFiles, err))
|
||||
}
|
||||
}
|
||||
panic(fmt.Sprintf("detected hanging go command (pid %d): see golang/go#54461 for more details", proc.Pid))
|
||||
}
|
||||
|
||||
func cmdDebugStr(cmd *exec.Cmd) string {
|
||||
env := make(map[string]string)
|
||||
for _, kv := range cmd.Env {
|
||||
|
|
13
vendor/golang.org/x/tools/internal/gocommand/version.go
generated
vendored
13
vendor/golang.org/x/tools/internal/gocommand/version.go
generated
vendored
|
@ -10,8 +10,15 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
// GoVersion checks the go version by running "go list" with modules off.
|
||||
// It returns the X in Go 1.X.
|
||||
// GoVersion reports the minor version number of the highest release
|
||||
// tag built into the go command on the PATH.
|
||||
//
|
||||
// Note that this may be higher than the version of the go tool used
|
||||
// to build this application, and thus the versions of the standard
|
||||
// go/{scanner,parser,ast,types} packages that are linked into it.
|
||||
// In that case, callers should either downgrade to the version of
|
||||
// go used to build the application, or report an error that the
|
||||
// application is too old to use the go command on the PATH.
|
||||
func GoVersion(ctx context.Context, inv Invocation, r *Runner) (int, error) {
|
||||
inv.Verb = "list"
|
||||
inv.Args = []string{"-e", "-f", `{{context.ReleaseTags}}`, `--`, `unsafe`}
|
||||
|
@ -38,7 +45,7 @@ func GoVersion(ctx context.Context, inv Invocation, r *Runner) (int, error) {
|
|||
if len(stdout) < 3 {
|
||||
return 0, fmt.Errorf("bad ReleaseTags output: %q", stdout)
|
||||
}
|
||||
// Split up "[go1.1 go1.15]"
|
||||
// Split up "[go1.1 go1.15]" and return highest go1.X value.
|
||||
tags := strings.Fields(stdout[1 : len(stdout)-2])
|
||||
for i := len(tags) - 1; i >= 0; i-- {
|
||||
var version int
|
||||
|
|
9
vendor/golang.org/x/tools/internal/imports/fix.go
generated
vendored
9
vendor/golang.org/x/tools/internal/imports/fix.go
generated
vendored
|
@ -807,6 +807,11 @@ type ProcessEnv struct {
|
|||
ModFlag string
|
||||
ModFile string
|
||||
|
||||
// SkipPathInScan returns true if the path should be skipped from scans of
|
||||
// the RootCurrentModule root type. The function argument is a clean,
|
||||
// absolute path.
|
||||
SkipPathInScan func(string) bool
|
||||
|
||||
// Env overrides the OS environment, and can be used to specify
|
||||
// GOPROXY, GO111MODULE, etc. PATH cannot be set here, because
|
||||
// exec.Command will not honor it.
|
||||
|
@ -1367,9 +1372,9 @@ func (r *gopathResolver) scan(ctx context.Context, callback *scanCallback) error
|
|||
return err
|
||||
}
|
||||
var roots []gopathwalk.Root
|
||||
roots = append(roots, gopathwalk.Root{filepath.Join(goenv["GOROOT"], "src"), gopathwalk.RootGOROOT})
|
||||
roots = append(roots, gopathwalk.Root{Path: filepath.Join(goenv["GOROOT"], "src"), Type: gopathwalk.RootGOROOT})
|
||||
for _, p := range filepath.SplitList(goenv["GOPATH"]) {
|
||||
roots = append(roots, gopathwalk.Root{filepath.Join(p, "src"), gopathwalk.RootGOPATH})
|
||||
roots = append(roots, gopathwalk.Root{Path: filepath.Join(p, "src"), Type: gopathwalk.RootGOPATH})
|
||||
}
|
||||
// The callback is not necessarily safe to use in the goroutine below. Process roots eagerly.
|
||||
roots = filterRoots(roots, callback.rootFound)
|
||||
|
|
22
vendor/golang.org/x/tools/internal/imports/mod.go
generated
vendored
22
vendor/golang.org/x/tools/internal/imports/mod.go
generated
vendored
|
@ -129,22 +129,22 @@ func (r *ModuleResolver) init() error {
|
|||
})
|
||||
|
||||
r.roots = []gopathwalk.Root{
|
||||
{filepath.Join(goenv["GOROOT"], "/src"), gopathwalk.RootGOROOT},
|
||||
{Path: filepath.Join(goenv["GOROOT"], "/src"), Type: gopathwalk.RootGOROOT},
|
||||
}
|
||||
r.mainByDir = make(map[string]*gocommand.ModuleJSON)
|
||||
for _, main := range r.mains {
|
||||
r.roots = append(r.roots, gopathwalk.Root{main.Dir, gopathwalk.RootCurrentModule})
|
||||
r.roots = append(r.roots, gopathwalk.Root{Path: main.Dir, Type: gopathwalk.RootCurrentModule})
|
||||
r.mainByDir[main.Dir] = main
|
||||
}
|
||||
if vendorEnabled {
|
||||
r.roots = append(r.roots, gopathwalk.Root{r.dummyVendorMod.Dir, gopathwalk.RootOther})
|
||||
r.roots = append(r.roots, gopathwalk.Root{Path: r.dummyVendorMod.Dir, Type: gopathwalk.RootOther})
|
||||
} else {
|
||||
addDep := func(mod *gocommand.ModuleJSON) {
|
||||
if mod.Replace == nil {
|
||||
// This is redundant with the cache, but we'll skip it cheaply enough.
|
||||
r.roots = append(r.roots, gopathwalk.Root{mod.Dir, gopathwalk.RootModuleCache})
|
||||
r.roots = append(r.roots, gopathwalk.Root{Path: mod.Dir, Type: gopathwalk.RootModuleCache})
|
||||
} else {
|
||||
r.roots = append(r.roots, gopathwalk.Root{mod.Dir, gopathwalk.RootOther})
|
||||
r.roots = append(r.roots, gopathwalk.Root{Path: mod.Dir, Type: gopathwalk.RootOther})
|
||||
}
|
||||
}
|
||||
// Walk dependent modules before scanning the full mod cache, direct deps first.
|
||||
|
@ -158,7 +158,7 @@ func (r *ModuleResolver) init() error {
|
|||
addDep(mod)
|
||||
}
|
||||
}
|
||||
r.roots = append(r.roots, gopathwalk.Root{r.moduleCacheDir, gopathwalk.RootModuleCache})
|
||||
r.roots = append(r.roots, gopathwalk.Root{Path: r.moduleCacheDir, Type: gopathwalk.RootModuleCache})
|
||||
}
|
||||
|
||||
r.scannedRoots = map[gopathwalk.Root]bool{}
|
||||
|
@ -466,6 +466,16 @@ func (r *ModuleResolver) scan(ctx context.Context, callback *scanCallback) error
|
|||
// We assume cached directories are fully cached, including all their
|
||||
// children, and have not changed. We can skip them.
|
||||
skip := func(root gopathwalk.Root, dir string) bool {
|
||||
if r.env.SkipPathInScan != nil && root.Type == gopathwalk.RootCurrentModule {
|
||||
if root.Path == dir {
|
||||
return false
|
||||
}
|
||||
|
||||
if r.env.SkipPathInScan(filepath.Clean(dir)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
info, ok := r.cacheLoad(dir)
|
||||
if !ok {
|
||||
return false
|
||||
|
|
418
vendor/golang.org/x/tools/internal/imports/zstdlib.go
generated
vendored
418
vendor/golang.org/x/tools/internal/imports/zstdlib.go
generated
vendored
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue