label

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2020 License: Apache-2.0 Imports: 6 Imported by: 97

Documentation

Overview

Package label provides utilities for parsing and manipulating Bazel labels. See https://docs.bazel.build/versions/master/build-ref.html#labels for more information.

Index

Constants

This section is empty.

Variables

View Source
var NoLabel = Label{}

NoLabel is the zero value of Label. It is not a valid label and may be returned when an error occurs.

Functions

func ImportPathToBazelRepoName

func ImportPathToBazelRepoName(importpath string) string

ImportPathToBazelRepoName converts a Go import path into a bazel repo name following the guidelines in http://bazel.io/docs/be/functions.html#workspace

Types

type Label

type Label struct {
	// Repo is the repository name. If omitted, the label refers to a target
	// in the current repository.
	Repo string

	// Pkg is the package name, which is usually the directory that contains
	// the target. If both Repo and Pkg are omitted, the label is relative.
	Pkg string

	// Name is the name of the target the label refers to. If omitted, Name
	// is assumed to be the same as Pkg.
	Name string

	// Relative indicates whether the label refers to a target in the current
	// package. Relative is true if and only if Repo and Pkg are both omitted.
	Relative bool
}

A Label represents a label of a build target in Bazel. Labels have three parts: a repository name, a package name, and a target name, formatted as @repo//pkg:target.

func New

func New(repo, pkg, name string) Label

New constructs a new label from components.

func Parse

func Parse(s string) (Label, error)

Parse reads a label from a string. See https://docs.bazel.build/versions/master/build-ref.html#lexi.

func (Label) Abs

func (l Label) Abs(repo, pkg string) Label

Abs computes an absolute label (one with a repository and package name) from this label. If this label is already absolute, it is returned unchanged.

func (Label) Contains

func (l Label) Contains(other Label) bool

Contains returns whether other is contained by the package of l or a sub-package. Neither label may be relative.

func (Label) Equal

func (l Label) Equal(other Label) bool

Equal returns whether two labels are exactly the same. It does not return true for different labels that refer to the same target.

func (Label) Rel

func (l Label) Rel(repo, pkg string) Label

Rel attempts to compute a relative label from this label. If this label is already relative or is in a different package, this label may be returned unchanged.

func (Label) String

func (l Label) String() string

Jump to

Keyboard shortcuts

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