protocol

package
v0.0.0-...-677f5df Latest Latest
Warning

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

Go to latest
Published: May 1, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WalkFlatPackagesFromJSON

func WalkFlatPackagesFromJSON(jsonFile string, onPkg PackageFunc) error

Types

type DriverRequest

type DriverRequest struct {
	Mode LoadMode `json:"mode"`
}

From https://github.com/golang/tools/blob/v0.1.0/go/packages/external.go#L32 Most fields are disabled since there is no need for them

func ReadDriverRequest

func ReadDriverRequest(r io.Reader) (*DriverRequest, error)

type DriverResponse

type DriverResponse struct {
	// NotHandled is returned if the request can't be handled by the current
	// driver. If an external driver returns a response with NotHandled, the
	// rest of the driverResponse is ignored, and go/packages will fallback
	// to the next driver. If go/packages is extended in the future to support
	// lists of multiple drivers, go/packages will fall back to the next driver.
	NotHandled bool

	// Sizes, if not nil, is the types.Sizes to use when type checking.
	Sizes *types.StdSizes

	// Roots is the set of package IDs that make up the root packages.
	// We have to encode this separately because when we encode a single package
	// we cannot know if it is one of the roots as that requires knowledge of the
	// graph it is part of.
	Roots []string `json:",omitempty"`

	// Packages is the full set of packages in the graph.
	// The packages are not connected into a graph.
	// The Imports if populated will be stubs that only have their ID set.
	// Imports will be connected and then type and syntax information added in a
	// later pass (see refine).
	Packages []*FlatPackage
}

DriverResponse is the GOPACKAGESDRIVER response object.

type FlatPackage

type FlatPackage struct {
	ID              string
	Name            string              `json:",omitempty"`
	PkgPath         string              `json:",omitempty"`
	Errors          []FlatPackagesError `json:",omitempty"`
	GoFiles         []string            `json:",omitempty"`
	CompiledGoFiles []string            `json:",omitempty"`
	OtherFiles      []string            `json:",omitempty"`
	ExportFile      string              `json:",omitempty"`
	Imports         map[string]string   `json:",omitempty"`
	Standard        bool                `json:",omitempty"`
}

FlatPackage is the JSON form of Package It drops all the type and syntax fields, and transforms the Imports

func (*FlatPackage) IsRoot

func (fp *FlatPackage) IsRoot() bool

func (*FlatPackage) IsStdlib

func (fp *FlatPackage) IsStdlib() bool

func (*FlatPackage) ResolvePaths

func (fp *FlatPackage) ResolvePaths(prf PathResolverFunc) error

type FlatPackagesError

type FlatPackagesError struct {
	Pos  string // "file:line:col" or "file:line" or "" or "-"
	Msg  string
	Kind FlatPackagesErrorKind
}

Copy and pasted from golang.org/x/tools/go/packages

func (FlatPackagesError) Error

func (err FlatPackagesError) Error() string

type FlatPackagesErrorKind

type FlatPackagesErrorKind int
const (
	UnknownError FlatPackagesErrorKind = iota
	ListError
	ParseError
	TypeError
)

type LoadMode

type LoadMode int

From https://pkg.go.dev/golang.org/x/tools/go/packages#LoadMode

const (
	// NeedName adds Name and PkgPath.
	NeedName LoadMode = 1 << iota

	// NeedFiles adds GoFiles and OtherFiles.
	NeedFiles

	// NeedCompiledGoFiles adds CompiledGoFiles.
	NeedCompiledGoFiles

	// NeedImports adds Imports. If NeedDeps is not set, the Imports field will contain
	// "placeholder" Packages with only the ID set.
	NeedImports

	// NeedDeps adds the fields requested by the LoadMode in the packages in Imports.
	NeedDeps

	// NeedExportsFile adds ExportFile.
	NeedExportsFile

	// NeedTypes adds Types, Fset, and IllTyped.
	NeedTypes

	// NeedSyntax adds Syntax.
	NeedSyntax

	// NeedTypesInfo adds TypesInfo.
	NeedTypesInfo

	// NeedTypesSizes adds TypesSizes.
	NeedTypesSizes

	// NeedModule adds Module.
	NeedModule
)

Only NeedExportsFile is needed in our case

func (LoadMode) String

func (m LoadMode) String() string

String returns the debug representation of the LoadMode int.

type PackageFunc

type PackageFunc func(pkg *FlatPackage)

type PathResolverFunc

type PathResolverFunc func(path string) string

Jump to

Keyboard shortcuts

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