fieldpath

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package fieldpath implements utilities for field paths as used in protobuf field masks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InternPathStrings

func InternPathStrings(s ...string) error

InternPathStrings interns the field path strings of t. This func is typically called from init(). It is not safe for concurrent use.

Types

type List

type List []Path

List is a list of field paths.

func ParseList

func ParseList(s ...string) (List, error)

ParseList parses field paths. The result is sorted.

func (List) AddPrefix

func (fps List) AddPrefix(prefix Path) List

AddPrefix returns a List with all elements of fps with the given prefix prepended.

func (List) Contains

func (fps List) Contains(search Path, exact bool) bool

Contains returns true if fps contains search or a prefix of search (if exact is false).

func (List) ContainsOnly

func (fps List) ContainsOnly(search List) bool

ContainsOnly returns true if the list contains only field paths present in search.

func (List) Filter

func (fps List) Filter(p func(Path) bool) List

Filter filters the fieldpaths by predicate p.

func (List) Len

func (fps List) Len() int

func (List) Less

func (fps List) Less(i, j int) bool

func (List) Map

func (fps List) Map(m func(Path) Path) List

Map returns a List containing the results of calling m on every element of fps.

func (List) MatchAll

func (fps List) MatchAll(p func(Path) bool) bool

MatchAll returns true if all elements of the list match predicate p.

func (List) MatchAny

func (fps List) MatchAny(p func(Path) bool) bool

MatchAny returns true if any element of the list matches predicate p.

func (List) RemovePrefix

func (fps List) RemovePrefix(prefix Path) List

RemovePrefix returns a List with all elements of fps that have the given prefix, but without that prefix.

func (List) Sort

func (fps List) Sort() List

Sort returns a sorted copy of the List.

func (List) String

func (fps List) String() string

func (List) Swap

func (fps List) Swap(i, j int)

func (List) Unique

func (fps List) Unique(exact bool) List

Unique returns a List containing the unique paths in the List. If the List contains a field and a prefix of that field, only the prefix will be in the result, unless exact is true. The result is sorted.

type Path

type Path []string

Path is the path to a field in a struct.

func Parse

func Parse(s string) (Path, error)

Parse parses a field path.

func (Path) Equal

func (fp Path) Equal(other Path) bool

Equal returns whether f is equal to other.

func (Path) HasPrefix

func (fp Path) HasPrefix(other Path) bool

HasPrefix returns whether f has other as a prefix.

func (Path) Join

func (fp Path) Join(elements ...string) Path

Join returns a Path that joins f together with the extra elements.

func (Path) String

func (fp Path) String() string

Jump to

Keyboard shortcuts

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