list

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: Apache-2.0 Imports: 0 Imported by: 16

README

list 🔗

GoDoc Build Status Codecov Go Report Card Version

Simple List-Manipulation Utilities for Go

This library replicates a number of useful functions that I still miss from other languages. Feel free to use, or add to this library accordingly.

Pull Requests Welcome

This library is a work in progress, and will benefit from your experience reports, use cases, and contributions. If you have an idea for making this library better, send in a pull request. We're all in this together! 🔗

Documentation

Index

Constants

View Source
const DelimiterComma = ','
View Source
const DelimiterDot = '.'
View Source
const DelimiterEqual = '='
View Source
const DelimiterSlash = '/'
View Source
const DelimiterSpace = ' '

Variables

This section is empty.

Functions

func At

func At(value []byte, delimiter byte, index int) []byte

at returns the list vaue at a particular index

func Head(value []byte, delimiter byte) []byte

Head returns the FIRST item in a list

func Index added in v0.3.0

func Index(value []byte, delimiter byte) int

Index finds the first occurrance of the delimiter (-1 if not found)

func IsEmpty added in v0.3.0

func IsEmpty(value []byte) bool

IsEmpty returns TRUE if the list is empty.

func IsEmptyTail added in v0.3.0

func IsEmptyTail(value []byte, delimiter byte) bool

IsEmptyTail returns TRUE if this list only has one element

func Last

func Last(value []byte, delimiter byte) []byte

Last returns the LAST item in a string-based-list

func LastIndex added in v0.3.0

func LastIndex(value []byte, delimiter byte) int

LastIndex finds the last occurrance of the delimiter (-1 if not found)

func PushHead

func PushHead(value []byte, newValue []byte, delimiter byte) []byte

PushHead adds a new item to the beginning of the list

func PushTail

func PushTail(value []byte, newValue []byte, delimiter byte) []byte

PushTail adds a new item to the end of the list

func RemoveLast

func RemoveLast(value []byte, delimiter byte) []byte

RemoveLast returns the full list, with the last element removed.

func Split

func Split(value []byte, delimiter byte) ([]byte, []byte)

Split returns the FIRST element, and the REST element in one function call

func SplitTail

func SplitTail(value []byte, delimiter byte) ([]byte, []byte)

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(value []byte, delimiter byte) []byte

Tail returns any values in the list AFTER the first item

Types

type Comma added in v0.3.0

type Comma []byte

func (Comma) At added in v0.3.0

func (list Comma) At(index int) string

func (Comma) Head added in v0.3.0

func (list Comma) Head() string

func (Comma) IsEmpty added in v0.3.0

func (list Comma) IsEmpty() bool

func (Comma) IsEmptyTail added in v0.3.0

func (list Comma) IsEmptyTail() bool

func (Comma) Last added in v0.3.0

func (list Comma) Last() string

func (Comma) PushHead added in v0.3.0

func (list Comma) PushHead(value string) Comma

func (Comma) PushTail added in v0.3.0

func (list Comma) PushTail(value string) Comma

func (Comma) RemoveLast added in v0.3.0

func (list Comma) RemoveLast() Comma

func (Comma) Split added in v0.3.0

func (list Comma) Split() (string, Comma)

func (Comma) SplitTail added in v0.3.0

func (list Comma) SplitTail() (Comma, string)

func (Comma) String added in v0.3.0

func (list Comma) String() string

func (Comma) Tail added in v0.3.0

func (list Comma) Tail() Comma

type Dot added in v0.3.0

type Dot []byte

func (Dot) At added in v0.3.0

func (list Dot) At(index int) string

func (Dot) Head added in v0.3.0

func (list Dot) Head() string

func (Dot) IsEmpty added in v0.3.0

func (list Dot) IsEmpty() bool

func (Dot) IsEmptyTail added in v0.3.0

func (list Dot) IsEmptyTail() bool

func (Dot) Last added in v0.3.0

func (list Dot) Last() string

func (Dot) PushHead added in v0.3.0

func (list Dot) PushHead(value string) Dot

func (Dot) PushTail added in v0.3.0

func (list Dot) PushTail(value string) Dot

func (Dot) RemoveLast added in v0.3.0

func (list Dot) RemoveLast() Dot

func (Dot) Split added in v0.3.0

func (list Dot) Split() (string, Dot)

func (Dot) SplitTail added in v0.3.0

func (list Dot) SplitTail() (Dot, string)

func (Dot) String added in v0.3.0

func (list Dot) String() string

func (Dot) Tail added in v0.3.0

func (list Dot) Tail() Dot

type Equal added in v0.3.0

type Equal []byte

func (Equal) At added in v0.3.0

func (list Equal) At(index int) string

func (Equal) Head added in v0.3.0

func (list Equal) Head() string

func (Equal) IsEmpty added in v0.3.0

func (list Equal) IsEmpty() bool

func (Equal) IsEmptyTail added in v0.3.0

func (list Equal) IsEmptyTail() bool

func (Equal) Last added in v0.3.0

func (list Equal) Last() string

func (Equal) PushHead added in v0.3.0

func (list Equal) PushHead(value string) Equal

func (Equal) PushTail added in v0.3.0

func (list Equal) PushTail(value string) Equal

func (Equal) RemoveLast added in v0.3.0

func (list Equal) RemoveLast() Equal

func (Equal) Split added in v0.3.0

func (list Equal) Split() (string, Equal)

func (Equal) SplitTail added in v0.3.0

func (list Equal) SplitTail() (Equal, string)

func (Equal) String added in v0.3.0

func (list Equal) String() string

func (Equal) Tail added in v0.3.0

func (list Equal) Tail() Equal

type Slash added in v0.3.0

type Slash []byte

func (Slash) At added in v0.3.0

func (list Slash) At(index int) string

func (Slash) Head added in v0.3.0

func (list Slash) Head() string

func (Slash) IsEmpty added in v0.3.0

func (list Slash) IsEmpty() bool

func (Slash) IsEmptyTail added in v0.3.0

func (list Slash) IsEmptyTail() bool

func (Slash) Last added in v0.3.0

func (list Slash) Last() string

func (Slash) PushHead added in v0.3.0

func (list Slash) PushHead(value string) Slash

func (Slash) PushTail added in v0.3.0

func (list Slash) PushTail(value string) Slash

func (Slash) RemoveLast added in v0.3.0

func (list Slash) RemoveLast() Slash

func (Slash) Split added in v0.3.0

func (list Slash) Split() (string, Slash)

func (Slash) SplitTail added in v0.3.0

func (list Slash) SplitTail() (Slash, string)

func (Slash) String added in v0.3.0

func (list Slash) String() string

func (Slash) Tail added in v0.3.0

func (list Slash) Tail() Slash

type Space added in v0.3.0

type Space []byte

func (Space) At added in v0.3.0

func (list Space) At(index int) string

func (Space) Head added in v0.3.0

func (list Space) Head() string

func (Space) IsEmpty added in v0.3.0

func (list Space) IsEmpty() bool

func (Space) IsEmptyTail added in v0.3.0

func (list Space) IsEmptyTail() bool

func (Space) Last added in v0.3.0

func (list Space) Last() string

func (Space) PushHead added in v0.3.0

func (list Space) PushHead(value string) Space

func (Space) PushTail added in v0.3.0

func (list Space) PushTail(value string) Space

func (Space) RemoveLast added in v0.3.0

func (list Space) RemoveLast() Space

func (Space) Split added in v0.3.0

func (list Space) Split() (string, Space)

func (Space) SplitTail added in v0.3.0

func (list Space) SplitTail() (Space, string)

func (Space) String added in v0.3.0

func (list Space) String() string

func (Space) Tail added in v0.3.0

func (list Space) Tail() Space

type Stringlike added in v0.3.0

type Stringlike interface {
	~string | []byte
}

Jump to

Keyboard shortcuts

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