Documentation ¶
Overview ¶
Package govname supports the creation of VName protobuf messages for Go packages and other entities.
Index ¶
- Constants
- func ArrayConstructorType(length int64) *spb.VName
- func BasicType(b *types.Basic) *spb.VName
- func ChanConstructorType(dir types.ChanDir) *spb.VName
- func ForBuiltin(signature string) *spb.VName
- func ForPackage(pkg *build.Package, opts *PackageVNameOptions) *spb.VName
- func ForStandardLibrary(importPath string) *spb.VName
- func FunctionConstructorType() *spb.VName
- func ImportPath(v *spb.VName, goRoot string) string
- func IsStandardLibrary(v *spb.VName) bool
- func MapConstructorType() *spb.VName
- func PointerConstructorType() *spb.VName
- func RepoRoot(importPath string) (*vcs.RepoRoot, error)
- func SliceConstructorType() *spb.VName
- func TupleConstructorType() *spb.VName
- func VariadicConstructorType() *spb.VName
- type PackageVNameOptions
Constants ¶
const Language = "go"
Language is the language string to use for Go VNames.
Variables ¶
This section is empty.
Functions ¶
func ArrayConstructorType ¶ added in v0.0.31
ArrayConstructorType returns the VName for the builtin Go array type constructor of a given length.
func ChanConstructorType ¶ added in v0.0.31
ChanConstructorType returns the VName for the builtin Go chan type constructor of the given direction.
func ForBuiltin ¶ added in v0.0.21
ForBuiltin returns a VName for a Go built-in with the given signature.
func ForPackage ¶
func ForPackage(pkg *build.Package, opts *PackageVNameOptions) *spb.VName
ForPackage returns a VName for a Go package.
A package VName has the fixed signature "package", and the VName path holds the import path relative to the corpus root. If the package's VCS root cannot be determined for the package's corpus, then by default the first path component of the import path is used as the corpus name, except for packages under GOROOT which are attributed to the special corpus "golang.org".
If a set of vname rules is provided, they are applied first and used if applicable. Note that vname rules are ignored for go stdlib packages.
Examples:
ForPackage(<kythe.io/kythe/go/util/schema>, &{CanonicalizePackageCorpus: false}) => { Corpus: "kythe.io", Path: "kythe/go/util/schema", Language: "go", Signature: "package", } ForPackage( <kythe.io/kythe/go/util/schema>, &{CanonicalizePackageCorpus: true}) => { Corpus: "github.com/kythe/kythe", Path: "kythe/go/util/schema", Language: "go", Signature: "package", } ForPackage(<github.com/kythe/kythe/kythe/go/util/schema>, &{CanonicalizePackageCorpus: false}) => { Corpus: "github.com/kythe/kythe", Path: "kythe/go/util/schema", Language: "go", Signature: "package", } ForPackage(<github.com/kythe/kythe/kythe/go/util/schema>, &{CanonicalizePackageCorpus: true}) => { Corpus: "github.com/kythe/kythe", Path: "kythe/go/util/schema", Language: "go", Signature: "package", }
func ForStandardLibrary ¶ added in v0.0.27
ForStandardLibrary returns a VName for a standard library package with the given import path.
func FunctionConstructorType ¶ added in v0.0.31
FunctionConstructorType returns the VName for the builtin Go function type constructor.
func ImportPath ¶ added in v0.0.30
ImportPath returns the putative Go import path corresponding to v. The resulting string corresponds to the string literal appearing in source at the import site for the package so named.
func IsStandardLibrary ¶ added in v0.0.14
IsStandardLibrary reports whether v names part of the Go standard library. This includes the "golang.org" corpus but excludes the "golang.org/x/..." extension repositories. If v == nil, the answer is false.
func MapConstructorType ¶ added in v0.0.31
MapConstructorType returns the VName for the builtin Go map type constructor.
func PointerConstructorType ¶ added in v0.0.31
PointerConstructorType returns the VName for the builtin Go pointer type constructor.
func SliceConstructorType ¶ added in v0.0.31
SliceConstructorType returns the VName for the builtin Go slice type constructor.
func TupleConstructorType ¶ added in v0.0.31
TupleConstructorType returns the VName for the builtin Go tuple type constructor.
func VariadicConstructorType ¶ added in v0.0.31
VariadicConstructorType returns the VName for the builtin Go variadic type constructor.
Types ¶
type PackageVNameOptions ¶ added in v0.0.30
type PackageVNameOptions struct { // DefaultCorpus optionally provides a fallback corpus name if a package // cannot otherwise be resolved to a corpus. DefaultCorpus string // CanonicalizePackageCorpus determines whether a package's corpus name is // canonicalized as its VCS repository root URL rather than the Go import path // corresponding to the VCS repository root. CanonicalizePackageCorpus bool // Rules optionally provides a list of rules to apply to go package and file // paths to customize output vnames. See the vnameutil package for details. Rules vnameutil.Rules // If set, file and package paths are made relative to this directory before // applying vname rules (if any). If unset, the module root (if using // modules) or the gopath directory is used instead. RootDirectory string }
PackageVNameOptions controls the construction of VNames for Go packages.