rope

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2019 License: MIT Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Golang Rope

A golang library for working with strings.

Documentation: click

This library gives you the object "Rope". A rope is braided with strings. So it is basically a collection of strings.

With the rope object, you're able to run functions on the whole collection. Most of the methods will return the rope itself which makes those method chainable.

Example

Let's say you received an HTTP-Request with this header information:

Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7

You want to know if theres a part which starts with de. All you have to do is creating a rope, split it by , and search the prefix de:

data := "de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7"
isGerman := rope.New(data).Split(",").AnyPrefix("de")

For more functions, see the documentation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rope

type Rope []string

Rope defines a collection of strings and provides useful functions to work with.

func New

func New(parts ...string) *Rope

New creates a new rope. Insert the parts (strings) to the rope as parameter 'parts'.

func (*Rope) AllContains

func (r *Rope) AllContains(substr string) bool

AllContains returns true, when all strings contain the parameter 'substr'.

func (*Rope) AllPrefix

func (r *Rope) AllPrefix(prefix string) bool

AllPrefix returns true, when all strings have the parameter 'prefix' as prefix.

func (*Rope) AllSuffix

func (r *Rope) AllSuffix(suffix string) bool

AllSuffix returns true, when all strings have the parameter 'suffix' as suffix.

func (*Rope) AnyContains

func (r *Rope) AnyContains(substr string) bool

AnyContains returns true, when any string exists, which contains the parameter 'substr'.

func (*Rope) AnyPrefix

func (r *Rope) AnyPrefix(prefix string) bool

AnyPrefix returns true, when any string exists, which has the parameter 'prefix' as prefix.

func (*Rope) AnySuffix

func (r *Rope) AnySuffix(suffix string) bool

AnySuffix returns true, when any string exists, which has the parameter 'suffix' as suffix.

func (*Rope) Append

func (r *Rope) Append(parts ...string) *Rope

Append appends strings to the rope.

func (*Rope) Get

func (r *Rope) Get(pos int) string

Get returns the part at the position 'pos'. If 'pos' is invalid, it returns an empty string.

func (*Rope) Has

func (r *Rope) Has(part string) bool

Has returns true, when the rope contains 'part'.

func (*Rope) Join

func (r *Rope) Join(glue string) *Rope

Join joins all parts together with 'glue' between. The result is a rope with only one string.

func (*Rope) Length

func (r *Rope) Length() int

Length returns the length of the first contained string.

func (*Rope) Lengths

func (r *Rope) Lengths() []int

Lengths returns a list of lengths of the strings.

func (*Rope) Prepend

func (r *Rope) Prepend(parts ...string) *Rope

Prepend prepends strings to the rope.

func (*Rope) RemoveEmpty

func (r *Rope) RemoveEmpty() *Rope

RemoveEmpty removes all empty strings of the rope.

func (*Rope) Size

func (r *Rope) Size() int

Size returns how many strings are stored in the rope.

func (*Rope) Split

func (r *Rope) Split(separator string) *Rope

Split splits all parts of the rope and adds them to the rope. E.g. if you have a,b and c,d and split by ",", you will have the four strings a, b, c and d in your rope.

func (*Rope) String

func (r *Rope) String() string

String returns the first string of the rope.

func (*Rope) Strings

func (r *Rope) Strings() []string

Strings is a convenient method for converting the rope to a string slice.

Jump to

Keyboard shortcuts

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