code

package
v0.17.5 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompatibleTypes

func CompatibleTypes(expected types.Type, actual types.Type) error

CompatibleTypes isnt a strict comparison, it allows for pointer differences

func ImportPathForDir

func ImportPathForDir(dir string) (res string)

ImportPathForDir takes a path and returns a golang import path for the package

func NameForDir added in v0.9.0

func NameForDir(dir string) string

NameForDir manually looks for package stanzas in files located in the given directory. This can be much faster than having to consult go list, because we already know exactly where to look.

func NormalizeVendor

func NormalizeVendor(pkg string) string

NormalizeVendor takes a qualified package path and turns it into normal one. eg . github.com/foo/vendor/github.com/99designs/gqlgen/graphql becomes github.com/99designs/gqlgen/graphql

func PkgAndType

func PkgAndType(name string) (string, string)

take a string in the form github.com/package/blah.Type and split it into package and type

func QualifyPackagePath

func QualifyPackagePath(importPath string) string

QualifyPackagePath takes an import and fully qualifies it with a vendor dir, if one is required. eg . github.com/99designs/gqlgen/graphql becomes github.com/foo/vendor/github.com/99designs/gqlgen/graphql

x/tools/packages only supports 'qualified package paths' so this will need to be done prior to calling it See https://github.com/golang/go/issues/30289

func SanitizePackageName

func SanitizePackageName(pkg string) string

Types

type Packages added in v0.11.0

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

Packages is a wrapper around x/tools/go/packages that maintains a (hopefully prewarmed) cache of packages that can be invalidated as writes are made and packages are known to change.

func (*Packages) Count added in v0.15.0

func (p *Packages) Count() int

func (*Packages) Errors added in v0.11.0

func (p *Packages) Errors() PkgErrors

Errors returns any errors that were returned by Load, either from the call itself or any of the loaded packages.

func (*Packages) Evict added in v0.11.0

func (p *Packages) Evict(importPath string)

Evict removes a given package import path from the cache, along with any packages that depend on it. Further calls to Load will fetch it from disk.

func (*Packages) Load added in v0.11.0

func (p *Packages) Load(importPath string) *packages.Package

Load works the same as LoadAll, except a single package at a time.

func (*Packages) LoadAll added in v0.11.0

func (p *Packages) LoadAll(importPaths ...string) []*packages.Package

LoadAll will call packages.Load and return the package data for the given packages, but if the package already have been loaded it will return cached values instead.

func (*Packages) LoadWithTypes added in v0.11.0

func (p *Packages) LoadWithTypes(importPath string) *packages.Package

LoadWithTypes tries a standard load, which may not have enough type info (TypesInfo== nil) available if the imported package is a second order dependency. Fortunately this doesnt happen very often, so we can just issue a load when we detect it.

func (*Packages) ModTidy added in v0.14.0

func (p *Packages) ModTidy() error

func (*Packages) NameForPackage added in v0.11.0

func (p *Packages) NameForPackage(importPath string) string

NameForPackage looks up the package name from the package stanza in the go files at the given import path.

func (*Packages) ReloadAll added in v0.15.0

func (p *Packages) ReloadAll(importPaths ...string) []*packages.Package

ReloadAll will call LoadAll after clearing the package cache, so we can reload packages in the case that the packages have changed

type PkgErrors added in v0.11.0

type PkgErrors []error

func (PkgErrors) Error added in v0.11.0

func (p PkgErrors) Error() string

Jump to

Keyboard shortcuts

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