gostr

package module
v0.0.0-...-497fda1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2022 License: MIT Imports: 7 Imported by: 10

README

goStr

Go Coverage Status GitHub go.mod Go version GitHub tag (latest SemVer) GoDoc License

A similar Python string from Go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set map[Str]struct{}

func NewSet

func NewSet[T ~[]E, E Stringer](s T) Set

NewSet new Set object of Str

Notice: Set is disorder!

func (Set) Add

func (s Set) Add(elems ...Str) Set

Add some elements to the Set

func (Set) Clone

func (s Set) Clone() Set

Clone a set of s

func (Set) In

func (s Set) In(ele Str) (ok bool)

In Check if the element is in a Set?

func (Set) Intersection

func (s Set) Intersection(s1 Set) Set

Intersection Get the intersection of s and s1

func (Set) Keys

func (s Set) Keys() Slice

Keys get all elements

Notice: this is disorder!

func (Set) Len

func (s Set) Len() int

Len get elements number

func (Set) ToSlice

func (s Set) ToSlice() Slice

ToSlice convert Slice type

func (Set) Union

func (s Set) Union(s1 Set) Set

Union Get the union of s and s1

type Slice

type Slice []Str

func NewSlice

func NewSlice[T ~[]E, E Stringer](t T) Slice

NewSlice create a slice of Str NewSlice create a slice of string

func (Slice) Append

func (s Slice) Append(elems ...Str) Slice

Append at the Slice tail add some elem.

func (Slice) CharSort

func (s Slice) CharSort(descending bool) Slice

CharSort character sorting,default ascending

func (Slice) Clone

func (s Slice) Clone() Slice

Clone get a Clone Slice data

func (Slice) Counter

func (s Slice) Counter() map[Str]int

Counter counts the number of elements

func (Slice) Deduplication

func (s Slice) Deduplication() Slice

Deduplication Remove duplicate data from string slice and return Notice: order

func (Slice) Delete

func (s Slice) Delete(ele Str) (ns Slice, err error)

Delete remove an element in Slice.

Returns err if the elements not exits in Slice or Slice.Len == 0.

func (Slice) Eq

func (s Slice) Eq(s1 Slice) bool

Eq compares two Slice to be same. Notice: ignoring String case from Slice.

func (Slice) In

func (s Slice) In(sub Str) bool

In Check if a string is in an array

func (Slice) Index

func (s Slice) Index(start int, end int) Slice

Index similar python string index

func (Slice) Join

func (s Slice) Join(sep Str) Str

Join concatenates the elements of its first argument to create a single string. The separator string sep is placed between elements in the resulting string.

func (Slice) Len

func (s Slice) Len() int

Len get slice length

Returns 0 if s==nil or len(s)==0

func (Slice) POP

func (s Slice) POP() (ns Slice, ele Str)

POP get the last element

func (Slice) Reverse

func (s Slice) Reverse() Slice

Reverse copy Any slice and positions reverse

func (Slice) ToSet

func (s Slice) ToSet() Set

ToSet convert strings slice to set

func (Slice) ToString

func (s Slice) ToString() []string

ToString convert String type

type Str

type Str string

func New

func New[T Stringer](str T) Str

New create new Str object

func (Str) Capitalize

func (str Str) Capitalize() Str

Capitalize Convert the first letter to uppercase

func (Str) Count

func (str Str) Count(substr Str) int

Count counts the number of non-overlapping instances of substr in s. If substr is an empty string, Count returns 1 + the number of Unicode code points in s.

func (Str) Digit

func (str Str) Digit() (int, error)

Digit Returns int if the string contains only numbers, otherwise returns Error

func (Str) EndsWith

func (str Str) EndsWith(suffix Str) bool

EndsWith tests whether the string s ends with suffix.

func (Str) Eq

func (str Str) Eq(s Str) bool

Eq compares two strings to be the same and not null. Notice: ignoring strings case.

func (Str) Find

func (str Str) Find(substr Str) int

Find returns the index of the first instance of substr in s, or -1 if substr is not present in s.

func (Str) In

func (str Str) In(substr Str) bool

In check if substr is in Str.

func (Str) Index

func (str Str) Index(start int, end int) Str

Index similar python string index

func (Str) IsALNum

func (str Str) IsALNum() bool

IsALNum Returns True if the string has at least one character and all characters are letters or numbers, otherwise returns False

func (Str) IsAlpha

func (str Str) IsAlpha() bool

IsAlpha Returns True if the string has at least one character and all characters are alphabets or Chinese characters, otherwise returns False

func (Str) IsLower

func (str Str) IsLower() bool

IsLower Returns True if the string contains at least one case-sensitive character and all of those (case-sensitive) characters are lowercase, False otherwise

func (Str) IsNumeric

func (str Str) IsNumeric() bool

IsNumeric Returns True if the string contains only numeric characters, otherwise returns False

func (Str) IsSpace

func (str Str) IsSpace() bool

IsSpace Returns True if the string contains only whitespace, otherwise returns False.

func (Str) IsUpper

func (str Str) IsUpper() bool

IsUpper Returns True if the string contains at least one case-sensitive character and all of those (case-sensitive) characters are uppercase, False otherwise

func (Str) Join

func (str Str) Join(elems []string) Str

Join concatenates the elements of its first argument to create a single string. The separator string str is placed between elements in the resulting string.

func (Str) LStrip

func (str Str) LStrip(cut Str) Str

LStrip returns a slice of the string s with all leading Unicode code points contained in cut removed.

To remove a prefix, use TrimPrefix instead.

func (Str) Len

func (str Str) Len() int

Len return string length

func (Str) Levenshtein

func (str Str) Levenshtein(s Str) float64

Levenshtein Fastest levenshtein implementation in Go.

this implementation is currently not thread safe, and it assumes that the runes only go up to 65535. This will be fixed soon. [Algorithm] https://github.com/ka-weihe/fast-levenshtein

func (Str) Lower

func (str Str) Lower() Str

Lower returns s with all Unicode letters mapped to their lower case.

func (Str) RStrip

func (str Str) RStrip(cut Str) Str

RStrip returns a slice of the string s, with all trailing Unicode code points contained in cut removed.

To remove a suffix, use TrimSuffix instead.

func (Str) Replace

func (str Str) Replace(old, new Str) Str

Replace returns a copy of the string s with all non-overlapping instances of old replaced by new. If old is empty, it matches at the beginning of the string and after each UTF-8 sequence, yielding up to k+1 replacements for a k-rune string.

func (Str) Runes

func (str Str) Runes() []rune

Runes Convert []rune in a string

func (Str) Split

func (str Str) Split(sep Str) Slice

Split slices s into all substrings separated by sep and returns a slice of the substrings between those separators.

func (Str) StartsWith

func (str Str) StartsWith(prefix Str) bool

StartsWith tests whether the string s begins with prefix.

func (Str) Strip

func (str Str) Strip(cut Str) Str

Strip returns a slice of the string s with all leading and trailing Unicode code points contained in cut removed.

func (Str) SwapCase

func (str Str) SwapCase() Str

SwapCase Convert uppercase to lowercase and lowercase to uppercase in a string

func (Str) Title

func (str Str) Title() Str

Title returns a copy of the string s with all Unicode letters mapped to their Unicode title case.

func (Str) ToString

func (str Str) ToString() string

ToString convert Str to string

func (Str) TrimPrefix

func (str Str) TrimPrefix(prefix Str) Str

TrimPrefix returns s without the provided leading prefix string. If s doesn't start with prefix, s is returned unchanged.

func (Str) TrimSpace

func (str Str) TrimSpace() Str

TrimSpace returns a slice of the string s, with all leading and trailing white space removed, as defined by Unicode.

func (Str) TrimSuffix

func (str Str) TrimSuffix(suffix Str) Str

TrimSuffix returns s without the provided trailing suffix string. If s doesn't end with suffix, s is returned unchanged.

func (Str) Upper

func (str Str) Upper() Str

Upper returns s with all Unicode letters mapped to their upper case.

type Stringer

type Stringer interface {
	~string | []byte | []rune
}

Stringer contains all characters type

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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