packages.go raw

   1  // Copyright 2020 The Go Authors. All rights reserved.
   2  // Use of this source code is governed by a BSD-style
   3  // license that can be found in the LICENSE file.
   4  
   5  // Package packagesinternal exposes internal-only fields from go/packages.
   6  package packagesinternal
   7  
   8  import "fmt"
   9  
  10  var GetDepsErrors = func(p any) []*PackageError { return nil }
  11  
  12  type PackageError struct {
  13  	ImportStack []string // shortest path from package named on command line to this one
  14  	Pos         string   // position of error (if present, file:line:col)
  15  	Err         string   // the error itself
  16  }
  17  
  18  func (err PackageError) String() string {
  19  	return fmt.Sprintf("%s: %s (import stack: %s)", err.Pos, err.Err, err.ImportStack)
  20  }
  21  
  22  var TypecheckCgo int
  23  var DepsErrors int // must be set as a LoadMode to call GetDepsErrors
  24