packages

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuildTags map[string]bool
View Source
var Goos string

These shouldn't change so we can have these as globals for easy reference

Functions

func ClearGlobalpkgs added in v1.1.2

func ClearGlobalpkgs()

func FindImportName

func FindImportName(file *ast.File, path string) *string

Find the local import name for an import path

func IsExcludeGoListError added in v1.1.2

func IsExcludeGoListError(errMessage string) bool

Types

type BuildConfig

type BuildConfig struct {
	Platforms []string
	GoFiles   []*GoFile
	Syntax    []*ast.File
	Override  map[string]*ExtGoFile
}

type ExtGoFile

type ExtGoFile struct {
	Path string

	Syntax *ast.File

	Meta any
}

type GoFile

type GoFile struct {
	Name string

	Syntax *ast.File

	IsCgo bool
}

func (*GoFile) String

func (gf *GoFile) String() string

type Importer

type Importer func(path string) (*types.Package, error)

type LoadOption

type LoadOption uint

Additional configuration options for load behaviour

const (
	LoadHaltMistyped LoadOption = 1 << iota // Halt loading on mistyped (reserved for stdlib packages)
	LoadAllConfigs                          // Load all source files and parse configs
)

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
	Dir        string
	ImportPath string
	Name       string
	Goroot     bool
	Export     string
	Module     *Module

	// Layer the package is on
	Layer *ProcGroup

	// Used in / Imported packages
	Parents []*Package
	Imports map[string]*Package

	// Build Configurations
	//
	// Index 0 is the default build configuration
	// The rest are ordered using the most generic unix-like ordering (see tags.go)
	Configs []BuildConfig

	// Active config
	//
	// Config to use when attempting a build
	CfgIdx int

	// Map file names and their import names to paths
	FileImports map[string]map[string]string

	// Fileset for loading all files for this package
	Fset *token.FileSet

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

	// Flags used for external processing (the porting package uses this, has no impact on load)
	ExtFlags uint8

	// Partially loaded type data
	Types *types.Package

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

func (*Package) Build

func (pkg *Package) Build(importer Importer, handleErr func(err TypeError)) (*types.Package, []TypeError)

Build the package

The package will be built according to the specified config (Package.Configs[Package.CfgIdx])

Pass in a non-nil importer function to override import calls Pass in a non-nil handleErr function to handle error calls as they appear

func (*Package) LoadSyntax

func (pkg *Package) LoadSyntax() (err error)

func (*Package) String

func (pkg *Package) String() string

type ProcGroup

type ProcGroup struct {
	Packages []*Package

	Next *ProcGroup

	Level int
}

func Load

func Load(paths []string, getOpts func(RawPackage, bool) (LoadOption, error)) (*ProcGroup, error)

type RawPackage

type RawPackage 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      *rawPackageError   // error loading package
	DepsErrors []*rawPackageError // 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 RefType

type RefType uint8

Information regarding how the package was discovered

const (
	Inactive   RefType = iota // Package is unused in default configuration
	Dependency                // Package would be built as it is dependended upon
	Main                      // Package was specified in provided arguments
)

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 (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