kytheuri

package
v0.0.67 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0, NCSA Imports: 7 Imported by: 23

Documentation

Overview

Package kytheuri provides a type to represent Kythe URIs. This package supports parsing a Kythe URI from a string, and converting back and forth between a Kythe URI and a Kythe VName protobuf message.

Index

Constants

View Source
const Scheme = "kythe:"

Scheme is the URI scheme label for Kythe.

Variables

This section is empty.

Functions

func Equal

func Equal(u1, u2 string) bool

Equal reports whether the two Kythe URI strings are equal in canonical form. If either URI is invalid, Equal returns false.

func Fix

func Fix(s string) (string, error)

Fix returns the canonical form of the given Kythe URI, if possible.

func ParseCorpusPath added in v0.0.59

func ParseCorpusPath(s string) (*cpb.CorpusPath, error)

ParseCorpusPath parses a Kythe URI and returns its CorpusPath components.

func ToString

func ToString(v *spb.VName) string

ToString renders the given VName into the standard string uri format.

func ToVName

func ToVName(s string) (*spb.VName, error)

ToVName parses the given string as a URI and returns an equivalent VName.

Types

type Raw added in v0.0.27

type Raw struct{ URI URI }

A Raw represents a parsed, "raw" Kythe URI whose field values are escaped. Use the Decode method to convert a *Raw to a plain *URI.

func ParseRaw added in v0.0.27

func ParseRaw(s string) (*Raw, error)

ParseRaw parses a Kythe URI from s, but does not unescape its fields. Use Parse to fully parse and unescape a URI, or call the Decode method of the returned value.

func (*Raw) Decode added in v0.0.27

func (r *Raw) Decode() (*URI, error)

Decode returns a *URI equivalent to r but with its field values unescaped.

func (*Raw) String added in v0.0.27

func (r *Raw) String() string

String renders r into the standard URI string format.

The resulting string is in canonical ordering, so if the URI was created by parsing a string, this may return a different string from that. However, parsing this string will always give back the same URI. If r == nil, it is treated as an empty URI.

type URI

type URI struct {
	Signature string
	Corpus    string
	Root      string
	Path      string
	Language  string
}

A URI represents a parsed, unescaped Kythe URI. A zero-valued URI is ready for use, representing the empty URI.

func FromCorpusPath added in v0.0.49

func FromCorpusPath(cp *cpb.CorpusPath) *URI

FromCorpusPath returns a Kythe URI for the given Kythe CorpusPath protobuf message.

func FromVName

func FromVName(v *spb.VName) *URI

FromVName returns a Kythe URI for the given Kythe VName protobuf message.

func MustParse

func MustParse(s string) *URI

MustParse returns the URI from parsing s, or panics in case of error.

func Parse

func Parse(s string) (*URI, error)

Parse parses and unescapes a Kythe URI from s. If s omits a scheme label, the "kythe" scheme is assumed.

func (*URI) CorpusPath added in v0.0.59

func (u *URI) CorpusPath() *cpb.CorpusPath

CorpusPath returns the CorpusPath components of the URI.

func (*URI) Encode added in v0.0.27

func (u *URI) Encode() *Raw

Encode returns an escaped "raw" Kythe URI equivalent to u.

func (*URI) Equal

func (u *URI) Equal(v *URI) bool

Equal reports whether u is equal to v.

func (*URI) String

func (u *URI) String() string

String renders the Kythe URI into the standard URI string format.

The resulting string is in canonical ordering, so if the URI was created by parsing a string, this may return a different string from that. However, parsing this string will always give back the same URI. If u == nil, it is treated as an empty URI.

func (*URI) VName

func (u *URI) VName() *spb.VName

VName converts the URI to an equivalent Kythe VName protobuf message.

Jump to

Keyboard shortcuts

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