Documentation
¶
Overview ¶
Package list provides functions for parsing and manipulating delimited strings as lists
Index ¶
- Constants
- func At[T Stringlike](value T, delimiter byte, index int) string
- func First[T Stringlike](value T, delimiter byte) string
- func First2(l List) (string, string)
- func First3(l List) (string, string, string)
- func First4(l List) (string, string, string, string)
- func Head[T Stringlike](value T, delimiter byte) string
- func Index[T Stringlike](value T, delimiter byte) int
- func IsEmpty[T Stringlike](value T) bool
- func IsEmptyTail[T Stringlike](value T, delimiter byte) bool
- func Last[T Stringlike](value T, delimiter byte) string
- func Last2(l List) (string, string)
- func Last3(l List) (string, string, string)
- func Last4(l List) (string, string, string, string)
- func LastIndex[T Stringlike](value T, delimiter byte) int
- func PushHead[T Stringlike](value T, headValue string, delimiter byte) T
- func PushTail[T Stringlike](value T, tailValue string, delimiter byte) T
- func RemoveLast[T Stringlike](value T, delimiter byte) T
- func Second(l List) string
- func Split[T Stringlike](value T, delimiter byte) (string, T)
- func SplitTail[T Stringlike](value T, delimiter byte) (T, string)
- func Tail[T Stringlike](value T, delimiter byte) T
- func Third(l List) string
- type Comma
- func (list Comma) At(index int) string
- func (list Comma) Bytes() []byte
- func (list Comma) First() string
- func (list Comma) Head() string
- func (list Comma) IsEmpty() bool
- func (list Comma) IsEmptyTail() bool
- func (list Comma) Last() string
- func (list Comma) PushHead(value string) List
- func (list Comma) PushTail(value string) List
- func (list Comma) RemoveLast() List
- func (list Comma) Split() (string, List)
- func (list Comma) SplitTail() (List, string)
- func (list Comma) String() string
- func (list Comma) Tail() List
- type Dot
- func (list Dot) At(index int) string
- func (list Dot) Bytes() []byte
- func (list Dot) First() string
- func (list Dot) Head() string
- func (list Dot) IsEmpty() bool
- func (list Dot) IsEmptyTail() bool
- func (list Dot) Last() string
- func (list Dot) PushHead(value string) List
- func (list Dot) PushTail(value string) List
- func (list Dot) RemoveLast() List
- func (list Dot) Split() (string, List)
- func (list Dot) SplitTail() (List, string)
- func (list Dot) String() string
- func (list Dot) Tail() List
- type Equal
- func (list Equal) At(index int) string
- func (list Equal) Bytes() []byte
- func (list Equal) First() string
- func (list Equal) Head() string
- func (list Equal) IsEmpty() bool
- func (list Equal) IsEmptyTail() bool
- func (list Equal) Last() string
- func (list Equal) PushHead(value string) List
- func (list Equal) PushTail(value string) List
- func (list Equal) RemoveLast() List
- func (list Equal) Split() (string, List)
- func (list Equal) SplitTail() (List, string)
- func (list Equal) String() string
- func (list Equal) Tail() List
- type List
- type Semicolon
- func (list Semicolon) At(index int) string
- func (list Semicolon) Bytes() []byte
- func (list Semicolon) First() string
- func (list Semicolon) Head() string
- func (list Semicolon) IsEmpty() bool
- func (list Semicolon) IsEmptyTail() bool
- func (list Semicolon) Last() string
- func (list Semicolon) PushHead(value string) List
- func (list Semicolon) PushTail(value string) List
- func (list Semicolon) RemoveLast() List
- func (list Semicolon) Split() (string, List)
- func (list Semicolon) SplitTail() (List, string)
- func (list Semicolon) String() string
- func (list Semicolon) Tail() List
- type Slash
- func (list Slash) At(index int) string
- func (list Slash) Bytes() []byte
- func (list Slash) First() string
- func (list Slash) Head() string
- func (list Slash) IsEmpty() bool
- func (list Slash) IsEmptyTail() bool
- func (list Slash) Last() string
- func (list Slash) PushHead(value string) List
- func (list Slash) PushTail(value string) List
- func (list Slash) RemoveLast() List
- func (list Slash) Split() (string, List)
- func (list Slash) SplitTail() (List, string)
- func (list Slash) String() string
- func (list Slash) Tail() List
- type Space
- func (list Space) At(index int) string
- func (list Space) Bytes() []byte
- func (list Space) First() string
- func (list Space) Head() string
- func (list Space) IsEmpty() bool
- func (list Space) IsEmptyTail() bool
- func (list Space) Last() string
- func (list Space) PushHead(value string) List
- func (list Space) PushTail(value string) List
- func (list Space) RemoveLast() List
- func (list Space) Split() (string, List)
- func (list Space) SplitTail() (List, string)
- func (list Space) String() string
- func (list Space) Tail() List
- type Stringlike
Constants ¶
const DelimiterComma = ','
DelimiterComma is the delimiter used by the Comma list type.
const DelimiterDot = '.'
DelimiterDot is the delimiter used by the Dot list type.
const DelimiterEqual = '='
DelimiterEqual is the delimiter used by the Equal list type.
const DelimiterSemicolon = ';'
DelimiterSemicolon is the delimiter used by the Semicolon list type.
const DelimiterSlash = '/'
DelimiterSlash is the delimiter used by the Slash list type.
const DelimiterSpace = ' '
DelimiterSpace is the delimiter used by the Space list type.
Variables ¶
This section is empty.
Functions ¶
func At ¶
func At[T Stringlike](value T, delimiter byte, index int) string
at returns the list vaue at a particular index
func First ¶ added in v0.7.0
func First[T Stringlike](value T, delimiter byte) string
First returns the FIRST item in a list (alias for Head)
func Head ¶
func Head[T Stringlike](value T, delimiter byte) string
Head returns the FIRST item in a list
func Index ¶ added in v0.3.0
func Index[T Stringlike](value T, delimiter byte) int
Index finds the first occurrance of the delimiter (-1 if not found)
func IsEmpty ¶ added in v0.3.0
func IsEmpty[T Stringlike](value T) bool
IsEmpty returns TRUE if the list is empty.
func IsEmptyTail ¶ added in v0.3.0
func IsEmptyTail[T Stringlike](value T, delimiter byte) bool
IsEmptyTail returns TRUE if this list only has one element
func Last ¶
func Last[T Stringlike](value T, delimiter byte) string
Last returns the LAST item in a T-based-list
func Last2 ¶ added in v0.18.3
Last2 returns the final two items in the list (last, then second-to-last).
func LastIndex ¶ added in v0.3.0
func LastIndex[T Stringlike](value T, delimiter byte) int
LastIndex finds the last occurrance of the delimiter (-1 if not found)
func PushHead ¶
func PushHead[T Stringlike](value T, headValue string, delimiter byte) T
PushHead adds a new item to the beginning of the list
func PushTail ¶
func PushTail[T Stringlike](value T, tailValue string, delimiter byte) T
PushTail adds a new item to the end of the list
func RemoveLast ¶
func RemoveLast[T Stringlike](value T, delimiter byte) T
RemoveLast returns the full list, with the last element removed.
func Split ¶
func Split[T Stringlike](value T, delimiter byte) (string, T)
Split returns the FIRST element, and the REST element in one function call
func SplitTail ¶
func SplitTail[T Stringlike](value T, delimiter byte) (T, string)
SplitTail behaves like split, but splits the beginning of the list from the last item in the list. So, the list "a,b,c" => "a,b", "c"
func Tail ¶
func Tail[T Stringlike](value T, delimiter byte) T
Tail returns any values in the list AFTER the first item
Types ¶
type Comma ¶ added in v0.3.0
type Comma string
Comma is a List backed by a comma-delimited string.
func (Comma) IsEmptyTail ¶ added in v0.3.0
IsEmptyTail returns TRUE if the list has no items after the head.
func (Comma) PushHead ¶ added in v0.3.0
PushHead returns a new list with the value prepended as the new head.
func (Comma) PushTail ¶ added in v0.3.0
PushTail returns a new list with the value appended as the new tail.
func (Comma) RemoveLast ¶ added in v0.3.0
RemoveLast returns a new list with the final item removed.
func (Comma) SplitTail ¶ added in v0.3.0
SplitTail returns a list of the leading items and the final item.
type Dot ¶ added in v0.3.0
type Dot string
Dot is a List backed by a dot-delimited string.
func (Dot) IsEmptyTail ¶ added in v0.3.0
IsEmptyTail returns TRUE if the list has no items after the head.
func (Dot) PushHead ¶ added in v0.3.0
PushHead returns a new list with the value prepended as the new head.
func (Dot) PushTail ¶ added in v0.3.0
PushTail returns a new list with the value appended as the new tail.
func (Dot) RemoveLast ¶ added in v0.3.0
RemoveLast returns a new list with the final item removed.
func (Dot) SplitTail ¶ added in v0.3.0
SplitTail returns a list of the leading items and the final item.
type Equal ¶ added in v0.3.0
type Equal string
Equal is a List backed by an equals-delimited string.
func (Equal) IsEmptyTail ¶ added in v0.3.0
IsEmptyTail returns TRUE if the list has no items after the head.
func (Equal) PushHead ¶ added in v0.3.0
PushHead returns a new list with the value prepended as the new head.
func (Equal) PushTail ¶ added in v0.3.0
PushTail returns a new list with the value appended as the new tail.
func (Equal) RemoveLast ¶ added in v0.3.0
RemoveLast returns a new list with the final item removed.
func (Equal) SplitTail ¶ added in v0.3.0
SplitTail returns a list of the leading items and the final item.
type List ¶ added in v0.6.0
type List interface {
IsEmpty() bool
IsEmptyTail() bool
Head() string
Tail() List
First() string
Last() string
RemoveLast() List
Split() (string, List)
SplitTail() (List, string)
At(index int) string
PushHead(value string) List
PushTail(value string) List
String() string
Bytes() []byte
}
List interface wraps all of the list manipulation methods implemented by standard lists in this library.
func BySemicolon ¶ added in v0.7.0
BySemicolon returns a List that joins/splits its items on semicolons.
type Semicolon ¶ added in v0.7.0
type Semicolon string
Semicolon is a List backed by a semicolon-delimited string.
func (Semicolon) At ¶ added in v0.7.0
At returns the item at the given index, or "" if out of range.
func (Semicolon) Bytes ¶ added in v0.8.1
Bytes returns the list as its underlying delimited byte slice.
func (Semicolon) IsEmptyTail ¶ added in v0.7.0
IsEmptyTail returns TRUE if the list has no items after the head.
func (Semicolon) PushHead ¶ added in v0.7.0
PushHead returns a new list with the value prepended as the new head.
func (Semicolon) PushTail ¶ added in v0.7.0
PushTail returns a new list with the value appended as the new tail.
func (Semicolon) RemoveLast ¶ added in v0.7.0
RemoveLast returns a new list with the final item removed.
func (Semicolon) Split ¶ added in v0.7.0
Split returns the head item and a list of the remaining items.
func (Semicolon) SplitTail ¶ added in v0.7.0
SplitTail returns a list of the leading items and the final item.
type Slash ¶ added in v0.3.0
type Slash string
Slash is a List backed by a slash-delimited string.
func (Slash) IsEmptyTail ¶ added in v0.3.0
IsEmptyTail returns TRUE if the list has no items after the head.
func (Slash) PushHead ¶ added in v0.3.0
PushHead returns a new list with the value prepended as the new head.
func (Slash) PushTail ¶ added in v0.3.0
PushTail returns a new list with the value appended as the new tail.
func (Slash) RemoveLast ¶ added in v0.3.0
RemoveLast returns a new list with the final item removed.
func (Slash) SplitTail ¶ added in v0.3.0
SplitTail returns a list of the leading items and the final item.
type Space ¶ added in v0.3.0
type Space string
Space is a List backed by a space-delimited string.
func (Space) IsEmptyTail ¶ added in v0.3.0
IsEmptyTail returns TRUE if the list has no items after the head.
func (Space) PushHead ¶ added in v0.3.0
PushHead returns a new list with the value prepended as the new head.
func (Space) PushTail ¶ added in v0.3.0
PushTail returns a new list with the value appended as the new tail.
func (Space) RemoveLast ¶ added in v0.3.0
RemoveLast returns a new list with the final item removed.
func (Space) SplitTail ¶ added in v0.3.0
SplitTail returns a list of the leading items and the final item.
type Stringlike ¶ added in v0.3.0
Stringlike constrains the underlying string-like types a list may be built from.