govname

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2019 License: Apache-2.0, NCSA Imports: 5 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 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".

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 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 RepoRoot added in v0.0.30

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

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

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
}

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