pkg2

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const CGO_PACKAGE_NAME = "C"
View Source
const GOLANGX_PATH_PREFIX = "golang.org/x/"
View Source
const UNSAFE_PACKAGE_NAME = "unsafe"

Variables

View Source
var FileSet = token.NewFileSet()

Functions

func ImportPathToAssumedName

func ImportPathToAssumedName(importPath string) (string, string)

func IsExcludeGoListError

func IsExcludeGoListError(errMessage string) bool

func IsGolangXPkg

func IsGolangXPkg(pkg *Package) bool

Package is a golang.org/x/... package

func IsStdlibPkg

func IsStdlibPkg(pkg *Package) bool

Types

type BuildConfig

type BuildConfig struct {
	Platforms []string
	Files     []*GoFile
	Syntax    []*ast.File
}

type GoFile

type GoFile struct {
	Name        string
	Path        string
	Cgo         bool
	Default     bool
	Syntax      *ast.File
	Tags        tags.Constraint
	Imports     map[string]string
	AnonImports []string
	Replaced    *ReplacedFile
}

func (*GoFile) String

func (gf *GoFile) String() string

type ImportTree

type ImportTree struct {
	// contains filtered or unexported fields
}

func List

func List(paths []string) (ImportTree, error)

Use go-list to load all packages and build the initial tree

We load as many packages as we can at once - and pick up any "unimported" packages (packages that were imported by source files not marked for build under the present system) Any unimported packages we then go and load ourselves (and continue this process until all packages are loaded)

func (*ImportTree) Groups

func (tree *ImportTree) Groups() [][]*Package

func (*ImportTree) Resolve

func (tree *ImportTree) Resolve() error

Perform recursive DFS on the tree

During the search: - Build topology - Check for cycles - Build exported types for packages

type JsonPackageError

type JsonPackageError struct {
	ImportStack []string // shortest path from package named on command line to this one
	Pos         string   // position of error (if present, file:line:col)
	Err         string   // the error itself
}

type MetaPackage

type MetaPackage struct {
	Dir        string // directory containing package sources
	ImportPath string // import path of package in dir
	// ImportComment string // path in import comment on package statement
	Name string // package name
	// Shlib         string // the shared library that contains this package (only set when -linkshared)
	Goroot   bool // is this package in the Go root?
	Standard bool // is this package part of the standard Go library?
	// Stale         bool   // would 'go install' do anything for this package?
	// StaleReason   string // explanation for Stale==true
	// Root string // Go root or Go path dir containing this package
	// ConflictDir   string // this directory shadows Dir in $GOPATH
	// BinaryOnly bool // binary-only package (no longer supported)
	// ForTest       string      // package is only for use in named test
	Export string // file containing export data (when using -export)
	// BuildID       string      // build ID of the compiled package (when using -export)
	Module  *Module  // info about package's containing module, if any (can be nil)
	Match   []string // command-line patterns matching this package
	DepOnly bool     // package is only a dependency, not explicitly

	// Source files
	GoFiles  []string // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
	CgoFiles []string // .go source files that import "C"
	// CompiledGoFiles   []string // .go files presented to compiler (when using -compiled)
	IgnoredGoFiles []string // .go source files ignored due to build constraints

	// Dependency information
	Imports   []string          // import paths used by this package
	ImportMap map[string]string // map from source import to ImportPath (identity entries omitted)

	// Error information
	Incomplete bool                // this package or a dependency has an error
	Error      *JsonPackageError   // error loading package
	DepsErrors []*JsonPackageError // errors loading dependencies
}

Fields that are commented out are provided by go-list however that are not need by wharf so leave them commented out in case they ever do become useful

type Module

type Module struct {
	Path string // module path
	// Query   string // version query corresponding to this version
	Version string // module version
	// Versions []string    // available module versions
	Replace *Module // replaced by this module
	// Time     *time.Time  // time version was created
	// Update     *Module      // available update (with -u)
	Main      bool   // is this the main module?
	Indirect  bool   // module is only indirectly needed by main module
	Dir       string // directory holding local copy of files, if any
	GoMod     string // path to go.mod file describing module, if any
	GoVersion string // go version used in module
	// Retracted  []string         // retraction information, if any (with -retracted or -u)
	// Deprecated string           // deprecation message, if any (with -u)
	Error *ModuleError // error loading module
}

type ModuleError

type ModuleError struct {
	Err string // the error itself
}

type Package

type Package struct {
	// Metadata
	Meta *MetaPackage

	// Builds
	Builds []BuildConfig

	// Files
	Files map[string]*GoFile

	// Packages it is imported by
	Parents []*Package
	// Imported packages
	Imports map[string]*Package

	// Whether or not the package would actually get built in the default environment
	Included bool

	// Set if the packages source has changed
	Dirty bool

	// Set if a dependency (direct or in-direct) is dirty
	DepDirty bool

	// Set if the package has been modified manually
	Modified bool

	// Set if this is the first time the package is loaded
	FirstLoad bool

	// Any errors that occurred during load
	Errors []error
	// contains filtered or unexported fields
}

func BackupNameLookup

func BackupNameLookup(name string) *Package

func (*Package) LoadSyntax

func (pkg *Package) LoadSyntax(build int) error

func (*Package) LookupImport

func (pkg *Package) LookupImport(pkgName string, fileName string) *Package

func (*Package) MarkModified

func (pkg *Package) MarkModified()

func (*Package) String

func (pkg *Package) String() string

type ReplacedFile

type ReplacedFile struct {
	File   *GoFile
	Reason any
}

type TCBadImportName

type TCBadImportName struct {
	Name    TCBadName
	PkgName string
}

type TCBadName

type TCBadName struct {
	MemberOf *string
	Name     string
}

type TCBadOther

type TCBadOther struct{}

type TypeErrId

type TypeErrId interface {
	// contains filtered or unexported methods
}

type TypeError

type TypeError struct {
	Err    types.Error
	Reason TypeErrId
}

func NewTypeCheckError

func NewTypeCheckError(err types.Error) (err2 TypeError)

func (TypeError) Error

func (err TypeError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL