govname

package
v0.0.54 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2021 License: Apache-2.0, NCSA Imports: 9 Imported by: 3

Documentation

Overview

Package govname supports the creation of VName protobuf messages for Go packages and other entities.

Index

Constants

View Source
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

func ArrayConstructorType(length int64) *spb.VName

ArrayConstructorType returns the VName for the builtin Go array type constructor of a given length.

func BasicType added in v0.0.31

func BasicType(b *types.Basic) *spb.VName

BasicType returns the VName for a basic builtin Go type.

func ChanConstructorType added in v0.0.31

func ChanConstructorType(dir types.ChanDir) *spb.VName

ChanConstructorType returns the VName for the builtin Go chan type constructor of the given direction.

func ForBuiltin added in v0.0.21

func ForBuiltin(signature string) *spb.VName

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

func ForStandardLibrary(importPath string) *spb.VName

ForStandardLibrary returns a VName for a standard library package with the given import path.

func FunctionConstructorType added in v0.0.31

func FunctionConstructorType() *spb.VName

FunctionConstructorType returns the VName for the builtin Go function type constructor.

func ImportPath added in v0.0.30

func ImportPath(v *spb.VName, goRoot string) string

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

func IsStandardLibrary(v *spb.VName) bool

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

func MapConstructorType() *spb.VName

MapConstructorType returns the VName for the builtin Go map type constructor.

func PointerConstructorType added in v0.0.31

func PointerConstructorType() *spb.VName

PointerConstructorType returns the VName for the builtin Go pointer type constructor.

func RepoRoot added in v0.0.30

func RepoRoot(importPath string) (*vcs.RepoRoot, error)

RepoRoot analyzes importPath to determine it's vcs.RepoRoot.

func SliceConstructorType added in v0.0.31

func SliceConstructorType() *spb.VName

SliceConstructorType returns the VName for the builtin Go slice type constructor.

func TupleConstructorType added in v0.0.31

func TupleConstructorType() *spb.VName

TupleConstructorType returns the VName for the builtin Go tuple type constructor.

func VariadicConstructorType added in v0.0.31

func VariadicConstructorType() *spb.VName

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.

Jump to

Keyboard shortcuts

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