Documentation
¶
Overview ¶
Package fqn contains tools to efficiently parse and operate on fully qualified names of format a.b.c or .a.b.c
Index ¶
- type Instance
- func (i Instance) HasRef() bool
- func (i Instance) Index(index int) string
- func (i Instance) IsAbsolute() bool
- func (i Instance) MaxDepth() int
- func (i Instance) NumberOfSegments() int
- func (i Instance) Parts() []string
- func (i Instance) PartsAtDepth(d int) []string
- func (i Instance) PathWithoutLeadingDot() string
- func (i Instance) String() string
- func (i Instance) StringAtDepth(d int) string
- func (i Instance) TrimmedSuffix(n int) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance holds a dotpath string view.
func Parse ¶
Parse takes a string pointer, keeps it as a reference.
NOTE: This tool is meant to use pointers in order to avoid copying data, because of this no updates to the input string can happen after calling Parse for the lifetime of this object.
func ParseString ¶
ParseString is similar to Parse but it safely copies the string which is less efficient but is safe.
func (Instance) HasRef ¶
HasRef returns whether or not this instance has an underlying string reference, if the result is false calling other methods can lead to a panic.
func (Instance) IsAbsolute ¶
IsAbsolute indicates whether this path is an absolute path. Absolute paths start with '.'
func (Instance) MaxDepth ¶
MaxDepth returns the maximum depth this path has.
Note that this depth is the largest depth index, not the count.
func (Instance) NumberOfSegments ¶
NumberOfSegments returns the number of segments in the dot-separated qualified name.
func (Instance) Parts ¶
Parts returns all segments, akin to strings.Split(input, ".") but it differs in implementation.
func (Instance) PartsAtDepth ¶
PartsAtDepth returns parts at a specific depth. At depth d, the leftmost d segments are excluded.
For instance:
If the path is "a.b.c", the parts at depth 1 are ["b", "c"].
func (Instance) PathWithoutLeadingDot ¶
PathWithoutLeadingDot returns the path with the leading dot trimmed.
func (Instance) StringAtDepth ¶
StringAtDepth returns the string at a specific depth from the right side. For instance, a depth of 0 for "a.b.c" returns "c" and a depth of 2 returns "a.b.c".
func (Instance) TrimmedSuffix ¶
TrimmedSuffix returns the path trimmed of n segments from the right. For instance, for n=0 and n=1 in path "a.b.c", trimmed result would be a.b.c and a.b