manip

package
v0.0.0-...-5c1fc54 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountRunes

func CountRunes(input string, r rune) (result int)

func DowncastSlice

func DowncastSlice(ss []string) (result []interface{})

func FirstDuplicate

func FirstDuplicate(input []string) (result string, ok bool)

func MakeOneLine

func MakeOneLine(s, repl string) (result string)

func SliceContains

func SliceContains(ss []string, findStr string) bool

func SlicesAreEqual

func SlicesAreEqual(a, b []interface{}) bool

func StringValuesEqualAfterSort

func StringValuesEqualAfterSort(a, b []string) bool

func Truncate

func Truncate(s string, i int) string

Types

type BasicSet

type BasicSet struct {
	// contains filtered or unexported fields
}

func NewBasicSet

func NewBasicSet(values []interface{}) (result *BasicSet)

func NewEmptyBasicSet

func NewEmptyBasicSet() (result *BasicSet)

func StringSet

func StringSet(values []string) (result *BasicSet)

func (*BasicSet) Add

func (s *BasicSet) Add(value interface{})

func (*BasicSet) AddSliceValues

func (s *BasicSet) AddSliceValues(values []interface{})

func (*BasicSet) Contains

func (s *BasicSet) Contains(value interface{}) (result bool)

func (*BasicSet) IsEmpty

func (s *BasicSet) IsEmpty() (result bool)

func (*BasicSet) Len

func (s *BasicSet) Len() (result int)

func (*BasicSet) Remove

func (s *BasicSet) Remove(value interface{})

func (*BasicSet) StringValues

func (s *BasicSet) StringValues() (result []string)

func (*BasicSet) Values

func (s *BasicSet) Values() (result []interface{})

type FileRange

type FileRange struct {
	StartLineNum int
	StartIndex   int
	EndLineNum   int
	EndIndex     int
}

func NewFileRange

func NewFileRange(startLineNum int, startIndex int, endLineNum int, endIndex int) (result *FileRange)

func NewFileRangeFromLineRange

func NewFileRangeFromLineRange(lineRange *LineRange, lineNum int) (result *FileRange)

func (*FileRange) DoLinesOverlap

func (r *FileRange) DoLinesOverlap(other *FileRange) bool

func (*FileRange) Overlaps

func (r *FileRange) Overlaps(other *FileRange) bool

type Filter

type Filter interface {
	IncludesAnything() bool
	Includes(interface{}) bool
	IncludesAllOf(items Set) bool
	IncludesAnyOf(items Set) bool
	FilterSet(Set)
	CanProvideExactValues() bool
	ExactValues() Set
}

type LineRange

type LineRange struct {
	StartIndex int
	EndIndex   int
}

func CodeContext

func CodeContext(contents string, codeRange, contextRangeInput *LineRange, limit int) (before, after *LineRange)

func CreateCodeContext

func CreateCodeContext(contents string, codeRange *LineRange, limit int) (result *LineRange)

func FindLineRange

func FindLineRange(val, sub string) (result *LineRange)

func NewLineRange

func NewLineRange(startIndex, endIndex int) (result *LineRange)

func NewLineRangeFromFileRange

func NewLineRangeFromFileRange(fileRange *FileRange, content string) (result *LineRange)

func (*LineRange) Equals

func (r *LineRange) Equals(other *LineRange) bool

func (*LineRange) ExtractValue

func (r *LineRange) ExtractValue(input string) (result *LineRangeValue)

func (*LineRange) HasContent

func (r *LineRange) HasContent() bool

func (*LineRange) Len

func (r *LineRange) Len() int

func (*LineRange) NewValue

func (r *LineRange) NewValue(valueString string) (result *LineRangeValue)

func (*LineRange) Overlaps

func (r *LineRange) Overlaps(other *LineRange) bool

func (*LineRange) Shifted

func (r *LineRange) Shifted(by int) (result *LineRange)

type LineRangeValue

type LineRangeValue struct {
	LineRange *LineRange
	Value     string
}

type Named

type Named interface {
	GetName() string
}

type Param

type Param struct {
	// contains filtered or unexported fields
}

A param is a struct, and a field that exists on that struct, or on a nested struct.

Usage:

type (

base    struct{ inner   inner }
inner   struct{ innerer innerer }
innerer struct{ foo     int }

)

func main() {
    a := base{inner{innerer{foo: 1}}}
    fmt.Print(NewBasicParam(&a, &a.inner.innerer.foo).PathName()) // prints "inner.innerer.foo"
    fmt.Print(NewBasicParam(&a, &a.foo).PathName())               // prints "inner.innerer.foo"
}

func NewBasicParam

func NewBasicParam(structPtr, leafFieldPtr interface{}) (result *Param)

func NewParam

func NewParam(structPtr, leafFieldPtr interface{}, tagName string, structFilter structFilterFunc) (result *Param)

func (*Param) LeafField

func (p *Param) LeafField() (result reflect.Value)

Returns a pointer to the field that was originally passed into the constructor

func (*Param) LeafFieldValue

func (p *Param) LeafFieldValue() (result interface{})

func (*Param) LeafStructField

func (p *Param) LeafStructField() (result reflect.StructField)

Returns the value of the field that was passed into the constructor

func (*Param) PathName

func (p *Param) PathName() (result string)

func (*Param) PathNamePieces

func (p *Param) PathNamePieces() (result []string)

func (*Param) SetLeafFieldValueFromString

func (p *Param) SetLeafFieldValueFromString(value interface{}) (err error)

func (*Param) String

func (p *Param) String() (result string)

type RegexpFilter

type RegexpFilter struct {
	// contains filtered or unexported fields
}

func NewRegexpExcludeFilter

func NewRegexpExcludeFilter(exclude []string) *RegexpFilter

func NewRegexpFilter

func NewRegexpFilter(included, exclude *RegexpSet) *RegexpFilter

func NewRegexpIncludeFilter

func NewRegexpIncludeFilter(include []string) *RegexpFilter

func NewStringRegexpFilter

func NewStringRegexpFilter(include, exclude []string) *RegexpFilter

Create from string slices

func (*RegexpFilter) CanProvideExactValues

func (f *RegexpFilter) CanProvideExactValues() bool

func (*RegexpFilter) ExactValues

func (f *RegexpFilter) ExactValues() Set

func (*RegexpFilter) FilterSet

func (f *RegexpFilter) FilterSet(items Set)

Returns only included items in a BasicSet object

func (*RegexpFilter) Includes

func (f *RegexpFilter) Includes(value interface{}) bool

Returns true if an item is included

func (*RegexpFilter) IncludesAllOf

func (f *RegexpFilter) IncludesAllOf(items Set) bool

func (*RegexpFilter) IncludesAnyOf

func (f *RegexpFilter) IncludesAnyOf(items Set) bool

func (*RegexpFilter) IncludesAnything

func (f *RegexpFilter) IncludesAnything() bool

Returns true if any string is included

type RegexpSet

type RegexpSet struct {
	// contains filtered or unexported fields
}

func NewRegexpSet

func NewRegexpSet(values []*regexp.Regexp) (result *RegexpSet)

func NewRegexpSetFromStringsMustCompile

func NewRegexpSetFromStringsMustCompile(values []string) (result *RegexpSet)

func (*RegexpSet) Add

func (r *RegexpSet) Add(i interface{})

func (*RegexpSet) AddSliceValues

func (r *RegexpSet) AddSliceValues(values []interface{})

func (*RegexpSet) Contains

func (r *RegexpSet) Contains(i interface{}) bool

func (*RegexpSet) FindStringSubmatchAny

func (r *RegexpSet) FindStringSubmatchAny(input string) (result []string)

func (*RegexpSet) FindStringSubmatchIndex

func (r *RegexpSet) FindStringSubmatchIndex(line string) (result []int, re *regexp.Regexp)

func (*RegexpSet) FirstMatchingRe

func (r *RegexpSet) FirstMatchingRe(input string) (result *regexp.Regexp)

func (*RegexpSet) IsEmpty

func (r *RegexpSet) IsEmpty() (result bool)

func (*RegexpSet) Len

func (r *RegexpSet) Len() int

func (*RegexpSet) MatchAny

func (r *RegexpSet) MatchAny(input string) (result bool)

func (*RegexpSet) ReValues

func (r *RegexpSet) ReValues() (result []*regexp.Regexp)

func (*RegexpSet) Remove

func (r *RegexpSet) Remove(item interface{})

func (*RegexpSet) Res

func (r *RegexpSet) Res() Set

func (*RegexpSet) StringValues

func (r *RegexpSet) StringValues() []string

func (*RegexpSet) Values

func (r *RegexpSet) Values() []interface{}

type Set

type Set interface {
	Add(interface{})
	AddSliceValues([]interface{})
	Remove(item interface{})
	Contains(interface{}) bool
	IsEmpty() bool
	Values() []interface{}
	Len() int
	StringValues() []string
}

type SliceFilter

type SliceFilter struct {
	// contains filtered or unexported fields
}

func ExcludeFilter

func ExcludeFilter(exclude []string) *SliceFilter

func IncludeFilter

func IncludeFilter(include []string) *SliceFilter

func NewSliceFilter

func NewSliceFilter(include, exclude Set) *SliceFilter

func StringFilter

func StringFilter(include, exclude []string) *SliceFilter

Create from string slices

func (*SliceFilter) CanProvideExactValues

func (i *SliceFilter) CanProvideExactValues() (result bool)

Returns true if an exact list of values that are included is available

func (*SliceFilter) ExactValues

func (i *SliceFilter) ExactValues() (result Set)

Exact list of values that are included

func (*SliceFilter) FilterSet

func (i *SliceFilter) FilterSet(items Set)

Returns only included items in a BasicSet object

func (*SliceFilter) Includes

func (i *SliceFilter) Includes(value interface{}) bool

Returns true if an item is included

func (*SliceFilter) IncludesAllOf

func (i *SliceFilter) IncludesAllOf(items Set) bool

Returns only included items in a BasicSet object

func (*SliceFilter) IncludesAnyOf

func (i *SliceFilter) IncludesAnyOf(items Set) bool

func (*SliceFilter) IncludesAnything

func (i *SliceFilter) IncludesAnything() bool

Returns true if any string is included

type StructParams

type StructParams struct {
	Params []*Param
}

func NewStructParams

func NewStructParams(structPtr interface{}, tagName string, structFilter structFilterFunc) (result *StructParams)

Jump to

Keyboard shortcuts

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