Documentation ¶
Index ¶
- Variables
- func AppendToFile(fileName string, s string) error
- func Big5ToUtf8(s []byte) ([]byte, error)
- func Big5ToUtf8String(s string) (string, error)
- func Contains(str string, substr string) bool
- func ContainsAny(s, chars string) bool
- func ContainsFloat32(s []float32, v float32) bool
- func ContainsFloat64(s []float64, v float64) bool
- func ContainsInt(s []int, v int) bool
- func ContainsInt32(s []int32, v int32) bool
- func ContainsInt64(s []int64, v int64) bool
- func ContainsRune(s string, r rune) bool
- func ContainsString(s []string, v string) bool
- func ContainsUInt(s []uint, v uint) bool
- func ContainsUInt32(s []uint32, v uint32) bool
- func ContainsUInt64(s []uint64, v uint64) bool
- func CountPlaceHolder(str string) (nHan int, nASCII int)
- func EqualFold(s, t string) bool
- func Fields(s string) []string
- func FieldsFunc(s string, f func(rune) bool) []string
- func FileLineCount(f string) (int, error)
- func FillLeft(s string, w int) string
- func FillRight(s string, w int) string
- func ForEachLine(br *bufio.Reader, callback func(string) error) error
- func GbkToUtf8(s []byte) ([]byte, error)
- func GbkToUtf8String(s string) (string, error)
- func GetAbbrString(str string, maxlen int, conSymbole string) string
- func GetAppDir() string
- func GetCurrPath() string
- func GetDate() string
- func GetDotDir() string
- func GetFuncName(level interface{}) string
- func GetHomeDir() string
- func GetTerminalSize() (height, width int)
- func GetTitle(browser string) (string, error)
- func GetTitleAndURL(browser string) (t, u string, err error)
- func GetURL(browser string) (string, error)
- func GologInit(infoHandle io.Writer, warnHandle io.Writer, errorHandle io.Writer, ...)
- func HasChineseChar(str string) bool
- func HasFile(filename string) bool
- func HasPrefix(str string, prefix string) bool
- func HasSuffix(str string, suffix string) bool
- func Index(s, substr string) int
- func IndexAny(s, chars string) int
- func IndexByte(s string, c byte) int
- func IndexFunc(s string, f func(rune) bool) int
- func IndexOf(n int, f func(int) bool) int
- func IndexOfFloat64(a []float64, x float64) int
- func IndexOfInt(a []int, x int) int
- func IndexOfInt32(a []int32, x int32) int
- func IndexOfInt64(a []int64, x int64) int
- func IndexOfString(a []string, x string) int
- func IndexOfUInt(a []uint, x uint) int
- func IndexOfUInt32(a []uint32, x uint32) int
- func IndexOfUInt64(a []uint64, x uint64) int
- func IndexRune(s string, r rune) int
- func IsDirExist(name string) bool
- func IsEqualString(a, b string, ignoreCase bool) bool
- func IsExist(name string) bool
- func IsFileExist(name string) bool
- func IsPathExist(path string) bool
- func Join(elems []string, sep string) string
- func LastIndex(s, substr string) int
- func LastIndexAny(s, chars string) int
- func LastIndexByte(s string, c byte) int
- func LastIndexFunc(s string, f func(rune) bool) int
- func LastIndexOf(n int, f func(int) bool) int
- func LastIndexOfFloat32(a []float32, x float32) int
- func LastIndexOfFloat64(a []float64, x float64) int
- func LastIndexOfInt(a []int, x int) int
- func LastIndexOfInt32(a []int32, x int32) int
- func LastIndexOfInt64(a []int64, x int64) int
- func LastIndexOfString(a []string, x string) int
- func LastIndexOfUInt(a []uint, x uint) int
- func LastIndexOfUInt32(a []uint32, x uint32) int
- func LastIndexOfUInt64(a []uint64, x uint64) int
- func LineCount(r io.Reader) (int, error)
- func MakeAll(path string) error
- func Map(mapping func(rune) rune, s string) string
- func Max(x interface{}) interface{}
- func MaxFloat32s(x ...float32) float32
- func MaxFloat64s(x ...float64) float64
- func MaxInt(i, j int) int
- func MaxInts(x ...int) int
- func MaxStrings(x ...string) string
- func Min(x interface{}) interface{}
- func MinFloat32s(x ...float32) float32
- func MinFloat64s(x ...float64) float64
- func MinInt(i, j int) int
- func MinInts(x ...int) int
- func MinStrings(x ...string) string
- func NewBuffer(buf []byte) *bytes.Buffer
- func NewBufioReader(s string) *bufio.Reader
- func NewRand() *rand.Rand
- func NewStringBuilder() *strings.Builder
- func NewStringReader(s string) *strings.Reader
- func NumberBanner(width int) string
- func PaddingBytes(bytes []byte, pad string) []byte
- func PaddingString(s string, pad string) string
- func RandomInt(min, max int) int
- func RandomString(n int, allowedChars ...[]rune) string
- func Repeat(s string, count int) string
- func Replace(s, old, new string, n int) string
- func ReplaceAll(s, old, new string) string
- func Reverse(s string) string
- func ReverseByte(s string) string
- func ReverseFloat32(s []float32) []float32
- func ReverseFloat64(s []float64) []float64
- func ReverseInt(s []int) []int
- func ReverseInt32(s []int32) []int32
- func ReverseInt64(s []int64) []int64
- func ReverseString(s string) string
- func ReverseStrings(s []string) []string
- func ReverseUInt(s []uint) []uint
- func ReverseUInt32(s []uint32) []uint32
- func ReverseUInt64(s []uint64) []uint64
- func RuneWidth(r rune) int
- func SetLoggerFieldsOrder(fields []string)
- func Shuffle(slice []interface{})
- func ShuffleFloat32(a []float32) []float32
- func ShuffleFloat64(a []float64) []float64
- func ShuffleInt(a []int) []int
- func ShuffleInt32(a []int32) []int32
- func ShuffleInt64(a []int64) []int64
- func ShuffleString(a []string) []string
- func ShuffleUInt(a []uint) []uint
- func ShuffleUInt32(a []uint32) []uint32
- func ShuffleUInt64(a []uint64) []uint64
- func Spaces(w int) string
- func Split(s, sep string) []string
- func SplitAfter(s, sep string) []string
- func SplitAfterN(s, sep string, n int) []string
- func SplitN(s, sep string, n int) []string
- func StringWidth(s string) int
- func Sum(x interface{}) interface{}
- func SumFloat32s(a ...float32) float32
- func SumFloat64s(a ...float64) float64
- func SumInts(a ...int) int
- func SumStrings(a ...string) string
- func Title(s string) string
- func ToLower(s string) string
- func ToTitle(s string) string
- func ToUpper(s string) string
- func Trim(s, cutset string) string
- func TrimBOM(line string) string
- func TrimFrontEndSpaceLine(content string) string
- func TrimFunc(s string, f func(rune) bool) string
- func TrimLeft(s, cutset string) string
- func TrimLeftFunc(s string, f func(rune) bool) string
- func TrimPrefix(s, prefix string) string
- func TrimRight(s, cutset string) string
- func TrimRightFunc(s string, f func(rune) bool) string
- func TrimSpace(s string) string
- func TrimSuffix(s, suffix string) string
- func Truncate(s string, w int, tail string) string
- func Utf8ToBig5(s []byte) ([]byte, error)
- func Utf8ToBig5String(s string) (string, error)
- func Utf8ToGbk(s []byte) ([]byte, error)
- func Utf8ToGbkString(s string) (string, error)
- func Wrap(s string, w int) string
- func WrapToSlice(s string, w int) []string
- type Align
- type LogFormatter
- type StrChain
- func (t *StrChain) Big5ToUtf8String() (*StrChain, error)
- func (t *StrChain) Bytes() []byte
- func (t *StrChain) Contains(substr string) bool
- func (t *StrChain) ContainsAny(chars string) bool
- func (t *StrChain) ContainsRune(r rune) bool
- func (t *StrChain) CountPlaceHolder() (nHan int, nASCII int)
- func (t *StrChain) EqualFold(s string) bool
- func (t *StrChain) Fields() []string
- func (t *StrChain) FieldsFunc(f func(rune) bool) []string
- func (t *StrChain) FillLeft(w int) *StrChain
- func (t *StrChain) FillRight(w int) *StrChain
- func (t *StrChain) GbkToUtf8String() (*StrChain, error)
- func (t *StrChain) GetAbbrString(maxlen int, contSymbol string) *StrChain
- func (t *StrChain) GetText() string
- func (t *StrChain) HasChineseChar() bool
- func (t *StrChain) HasPrefix(prefix string) bool
- func (t *StrChain) HasSuffix(suffix string) bool
- func (t *StrChain) Index(substr string) int
- func (t *StrChain) IndexAny(chars string) int
- func (t *StrChain) IndexByte(c byte) int
- func (t *StrChain) IndexFunc(f func(rune) bool) int
- func (t *StrChain) IndexRune(r rune) int
- func (t *StrChain) IsEqualString(b string, ignoreCase bool) bool
- func (t *StrChain) LastIndex(substr string) int
- func (t *StrChain) LastIndexAny(chars string) int
- func (t *StrChain) LastIndexByte(c byte) int
- func (t *StrChain) LastIndexFunc(f func(rune) bool) int
- func (t *StrChain) Len() int
- func (t *StrChain) Map(mapping func(rune) rune) *StrChain
- func (t *StrChain) NewStrChain(s string) *StrChain
- func (t *StrChain) NumberBanner() *StrChain
- func (t *StrChain) Repeat(count int) *StrChain
- func (t *StrChain) Replace(old, new string, n int) *StrChain
- func (t *StrChain) ReplaceAll(old, new string) *StrChain
- func (t *StrChain) Reverse() *StrChain
- func (t *StrChain) ReverseByte() *StrChain
- func (t *StrChain) Runes() []rune
- func (t *StrChain) SetText(txt string) *StrChain
- func (t *StrChain) Split(sep string) []string
- func (t *StrChain) SplitAfter(sep string) []string
- func (t *StrChain) SplitAfterN(sep string, n int) []string
- func (t *StrChain) SplitN(sep string, n int) []string
- func (t *StrChain) String() string
- func (t *StrChain) StringWidth() int
- func (t *StrChain) Title() *StrChain
- func (t *StrChain) ToLower() *StrChain
- func (t *StrChain) ToTitle() *StrChain
- func (t *StrChain) ToUpper() *StrChain
- func (t *StrChain) Trim(cutset string) *StrChain
- func (t *StrChain) TrimBOM() *StrChain
- func (t *StrChain) TrimFrontEndSpaceLine() *StrChain
- func (t *StrChain) TrimFunc(f func(rune) bool) *StrChain
- func (t *StrChain) TrimLeft(cutset string) *StrChain
- func (t *StrChain) TrimLeftFunc(f func(rune) bool) *StrChain
- func (t *StrChain) TrimPrefix(prefix string) *StrChain
- func (t *StrChain) TrimRight(cutset string) *StrChain
- func (t *StrChain) TrimRightFunc(f func(rune) bool) *StrChain
- func (t *StrChain) TrimSpace() *StrChain
- func (t *StrChain) TrimSuffix(suffix string) *StrChain
- func (t *StrChain) Truncate(w int, tail string) *StrChain
- func (t *StrChain) Utf8ToBig5String() (*StrChain, error)
- func (t *StrChain) Utf8ToGbkString() (*StrChain, error)
- func (t *StrChain) Wrap(w int) *StrChain
- type TableFormat
- func (t *TableFormat) NFields() int
- func (t *TableFormat) Prepare(w io.Writer)
- func (t *TableFormat) PrintEnd()
- func (t *TableFormat) PrintMiddleSepLine()
- func (t *TableFormat) PrintRow(rows ...interface{})
- func (t *TableFormat) PrintSart() error
- func (t *TableFormat) SetAfterMessage(msg string)
- func (t *TableFormat) SetBeforeMessage(msg string)
- func (t *TableFormat) SetWrapFields()
- type TextBuilder
- func (t *TextBuilder) Big5ToUtf8String() (TextTools, error)
- func (t *TextBuilder) Contains(substr string) bool
- func (t *TextBuilder) ContainsAny(chars string) bool
- func (t *TextBuilder) ContainsRune(r rune) bool
- func (t *TextBuilder) CountPlaceHolder() (nHan int, nASCII int)
- func (t *TextBuilder) EqualFold(s string) bool
- func (t *TextBuilder) Fields() []string
- func (t *TextBuilder) FieldsFunc(f func(rune) bool) []string
- func (t *TextBuilder) GbkToUtf8String() (TextTools, error)
- func (t *TextBuilder) GetAbbrString(maxlen int, contSymbol string) TextTools
- func (t *TextBuilder) GetText() string
- func (t *TextBuilder) HasChineseChar() bool
- func (t *TextBuilder) HasPrefix(prefix string) bool
- func (t *TextBuilder) HasSuffix(suffix string) bool
- func (t *TextBuilder) Index(substr string) int
- func (t *TextBuilder) IndexAny(chars string) int
- func (t *TextBuilder) IndexByte(c byte) int
- func (t *TextBuilder) IndexFunc(f func(rune) bool) int
- func (t *TextBuilder) IndexRune(r rune) int
- func (t *TextBuilder) IsEqualString(b string, ignoreCase bool) bool
- func (t *TextBuilder) LastIndex(substr string) int
- func (t *TextBuilder) LastIndexAny(chars string) int
- func (t *TextBuilder) LastIndexByte(c byte) int
- func (t *TextBuilder) LastIndexFunc(f func(rune) bool) int
- func (t *TextBuilder) Map(mapping func(rune) rune) TextTools
- func (t *TextBuilder) NewTextBuilder(s string) TextTools
- func (t *TextBuilder) NumberBanner() TextTools
- func (t *TextBuilder) Repeat(count int) TextTools
- func (t *TextBuilder) Replace(old, new string, n int) TextTools
- func (t *TextBuilder) ReplaceAll(old, new string) TextTools
- func (t *TextBuilder) Reverse() TextTools
- func (t *TextBuilder) SetText(txt string) TextTools
- func (t *TextBuilder) Split(sep string) []string
- func (t *TextBuilder) SplitAfter(sep string) []string
- func (t *TextBuilder) SplitAfterN(sep string, n int) []string
- func (t *TextBuilder) SplitN(sep string, n int) []string
- func (t *TextBuilder) String() string
- func (t *TextBuilder) Title() TextTools
- func (t *TextBuilder) ToLower() TextTools
- func (t *TextBuilder) ToTitle() TextTools
- func (t *TextBuilder) ToUpper() TextTools
- func (t *TextBuilder) Trim(cutset string) TextTools
- func (t *TextBuilder) TrimBOM() TextTools
- func (t *TextBuilder) TrimFrontEndSpaceLine() TextTools
- func (t *TextBuilder) TrimFunc(f func(rune) bool) TextTools
- func (t *TextBuilder) TrimLeft(cutset string) TextTools
- func (t *TextBuilder) TrimLeftFunc(f func(rune) bool) TextTools
- func (t *TextBuilder) TrimPrefix(prefix string) TextTools
- func (t *TextBuilder) TrimRight(cutset string) TextTools
- func (t *TextBuilder) TrimRightFunc(f func(rune) bool) TextTools
- func (t *TextBuilder) TrimSpace() TextTools
- func (t *TextBuilder) TrimSuffix(suffix string) TextTools
- func (t *TextBuilder) Utf8ToBig5String() (TextTools, error)
- func (t *TextBuilder) Utf8ToGbkString() (TextTools, error)
- type TextTools
- Bugs
Constants ¶
This section is empty.
Variables ¶
var ( // Log is a logger use logrus Log = logrus.New() )
Functions ¶
func AppendToFile ¶
AppendToFile append string `s` to file `fileName`
func Big5ToUtf8String ¶
Big5ToUtf8String decodes Big5 to UTF8
func ContainsAny ¶
ContainsAny reports whether any Unicode code points in `chars` are within `s`.
Encapsulates ContainsAny(s, chars string) bool
func ContainsFloat32 ¶
ContainsFloat32 returns true if a float32 is present in a iteratee.
func ContainsFloat64 ¶
ContainsFloat64 returns true if a float64 is present in a iteratee.
func ContainsInt ¶
ContainsInt returns true if an int is present in a iteratee.
func ContainsInt32 ¶
ContainsInt32 returns true if an int32 is present in a iteratee.
func ContainsInt64 ¶
ContainsInt64 returns true if an int64 is present in a iteratee.
func ContainsRune ¶
ContainsRune reports whether the Unicode code point `r` is within `s`.
Encapsulates strings.ContainsRune(s string, r rune) bool
func ContainsString ¶
ContainsString returns true if a string is present in a iteratee.
func ContainsUInt ¶
ContainsUInt returns true if an uint is present in a iteratee.
func ContainsUInt32 ¶
ContainsUInt32 returns true if an uint32 is present in a iteratee.
func ContainsUInt64 ¶
ContainsUInt64 returns true if an uint64 is present in a iteratee.
func CountPlaceHolder ¶
CountPlaceHolder return `nHan` and `nASCII`
`nHan`: number of occupied space in screen for han-character `nASCII`: number of occupied space in screen for ASCII-character
func EqualFold ¶
EqualFold reports whether `s` and `t`, interpreted as UTF-8 strings, are equal under Unicode case-folding, which is a more general form of case-insensitivity.
Encapsulates strings.EqualFold(s, t string) bool
func Fields ¶
Fields splits the string s around each instance of one or more consecutive white space characters, as defined by unicode.IsSpace, returning a slice of substrings of s or an empty slice if s contains only white space.
Encapsulates strings.Fields(s string) []string
Example
package main import ( "fmt" "strings" ) func main() { fmt.Printf("Fields are: %q", strings.Fields(" foo bar baz ")) } result: Fields are: ["foo" "bar" "baz"]
func FieldsFunc ¶
FieldsFunc splits the string s at each run of Unicode code points c satisfying f(c) and returns an array of slices of s. If all code points in s satisfy f(c) or the string is empty, an empty slice is returned.
FieldsFunc makes no guarantees about the order in which it calls f(c) and assumes that f always returns the same value for a given c.
Example
package main import ( "fmt" "strings" "unicode" ) func main() { f := func(c rune) bool { return !unicode.IsLetter(c) && !unicode.IsNumber(c) } fmt.Printf("Fields are: %q", strings.FieldsFunc(" foo1;bar2,baz3...", f)) } result: Fields are: ["foo1" "bar2" "baz3"]
func FileLineCount ¶
FileLineCount counts the number of '\n' for file f
`f` could be `gzip` file or plain text file
modify from "github.com/liuzl/goutil"
func ForEachLine ¶
ForEachLine higher order function that processes each line of text by callback function. The last non-empty line of input will be processed even if it has no newline.
`br` : read from `br` reader `callback` : the function used to treatment the each line from `br`
modify from "github.com/liuzl/goutil"
func GbkToUtf8String ¶
GbkToUtf8String decodes GBK to UTF8
func GetAbbrString ¶
GetAbbrString return the abbreviation string 'xxx...' of `str`
`maxlen`: maimium length of the abbreviation `conSymbole`: tailing symbol of the abbreviation
func GetDate ¶
func GetDate() string
GetDate get the current date and return string. For example,
if time.Now().Date() is `2020 November 27` then GetDate() return `Nov 27, 2020`
func GetTerminalSize ¶
func GetTerminalSize() (height, width int)
GetTerminalSize get size of console using `stty size`
func GetTitleAndURL ¶
GetTitleAndURL get the `title` and `UTL` of active tab of the current window of `browser`
`browser`: "edge" for "Microsoft Edge" (default) "chrome" for "Google Chrome"
func HasChineseChar ¶
HasChineseChar return true for that `str` include chinese character
Example:
HasChineseChar("abc 中文") return true HasChineseChar("abccefgh") return false
func Index ¶
Index returns the index of the first instance of substr in s, or -1 if substr is not present in s.
Example
package main import ( "fmt" "strings" ) func main() { fmt.Println(strings.Index("chicken", "ken")) // 4 fmt.Println(strings.Index("chicken", "dmr")) // -1 }
func IndexAny ¶
IndexAny returns the index of the first instance of any Unicode code point from chars in s, or -1 if no Unicode code point from chars is present in s.
Example
package main import ( "fmt" "strings" ) func main() { fmt.Println(strings.IndexAny("chicken", "aeiouy")) // 2 fmt.Println(strings.IndexAny("crwth", "aeiouy")) // -1 }
func IndexByte ¶
IndexByte returns the index of the first instance of c in s, or -1 if c is not present in s.
Example
package main import ( "fmt" "strings" ) func main() { fmt.Println(strings.IndexByte("golang", 'g')) // 0 fmt.Println(strings.IndexByte("gophers", 'h')) // 3 fmt.Println(strings.IndexByte("golang", 'x')) // -1 } result:
func IndexFunc ¶
IndexFunc returns the index into s of the first Unicode code point satisfying f(c), or -1 if none do.
Example
package main import ( "fmt" "strings" "unicode" ) func main() { f := func(c rune) bool { return unicode.Is(unicode.Han, c) } fmt.Println(strings.IndexFunc("Hello, 世界", f)) // 7 fmt.Println(strings.IndexFunc("Hello, world", f)) // -1 }
func IndexOf ¶
IndexOf gets the index at which the first occurrence of an value is found in array or return -1. if the value cannot be found
func IndexOfFloat64 ¶
IndexOfFloat64 gets the index at which the first occurrence of an float64 value is found in array or return -1 if the value cannot be found
func IndexOfInt ¶
IndexOfInt gets the index at which the first occurrence of an int value is found in array or return -1 if the value cannot be found
func IndexOfInt32 ¶
IndexOfInt32 gets the index at which the first occurrence of an int32 value is found in array or return -1 if the value cannot be found
func IndexOfInt64 ¶
IndexOfInt64 gets the index at which the first occurrence of an int64 value is found in array or return -1 if the value cannot be found
func IndexOfString ¶
IndexOfString gets the index at which the first occurrence of a string value is found in array or return -1 if the value cannot be found
func IndexOfUInt ¶
IndexOfUInt gets the index at which the first occurrence of an uint value is found in array or return -1 if the value cannot be found
func IndexOfUInt32 ¶
IndexOfUInt32 gets the index at which the first occurrence of an uint32 value is found in array or return -1 if the value cannot be found
func IndexOfUInt64 ¶
IndexOfUInt64 gets the index at which the first occurrence of an uint64 value is found in array or return -1 if the value cannot be found
func IndexRune ¶
IndexRune returns the index of the first instance of the Unicode code point r, or -1 if rune is not present in s. If r is utf8.RuneError, it returns the first instance of any invalid UTF-8 byte sequence.
Example
package main import ( "fmt" "strings" ) func main() { fmt.Println(strings.IndexRune("chicken", 'k')) // 4 fmt.Println(strings.IndexRune("chicken", 'd')) // -1 }
func IsDirExist ¶
IsDirExist reports whether the dir exists as a boolean
func IsEqualString ¶
IsEqualString compares string `a` and `b`
func IsFileExist ¶
IsFileExist reports whether the named file exists as a boolean
func Join ¶
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.
Example
package main import ( "fmt" "strings" ) func main() { s := []string{"foo", "bar", "baz"} fmt.Println(strings.Join(s, ", ")) // foo, bar, baz }
func LastIndex ¶
LastIndex returns the index of the last instance of substr in s, or -1 if substr is not present in s.
Example
package main import ( "fmt" "strings" ) func main() { fmt.Println(strings.Index("go gopher", "go")) // 0 fmt.Println(strings.LastIndex("go gopher", "go")) // 3 fmt.Println(strings.LastIndex("go gopher", "rodent")) // -1 }
func LastIndexAny ¶
LastIndexAny returns the index of the last instance of any Unicode code point from chars in s, or -1 if no Unicode code point from chars is present in s.
Example
package main import ( "fmt" "strings" ) func main() { fmt.Println(strings.LastIndexAny("go gopher", "go")) // 4 fmt.Println(strings.LastIndexAny("go gopher", "rodent")) // 8 fmt.Println(strings.LastIndexAny("go gopher", "fail")) // -1 }
func LastIndexByte ¶
LastIndexByte returns the index of the last instance of c in s, or -1 if c is not present in s.
Example
package main import ( "fmt" "strings" ) func main() { fmt.Println(strings.LastIndexByte("Hello, world", 'l')) // 10 fmt.Println(strings.LastIndexByte("Hello, world", 'o')) // 8 fmt.Println(strings.LastIndexByte("Hello, world", 'x')) // -1 }
func LastIndexFunc ¶
LastIndexFunc returns the index into s of the last Unicode code point satisfying f(c), or -1 if none do.
Example
package main import ( "fmt" "strings" "unicode" ) func main() { fmt.Println(strings.LastIndexFunc("go 123", unicode.IsNumber)) // 5 fmt.Println(strings.LastIndexFunc("123 go", unicode.IsNumber)) // 2 fmt.Println(strings.LastIndexFunc("go", unicode.IsNumber)) // -1 }
func LastIndexOf ¶
LastIndexOf gets the index at which the first occurrence of an value is found in array or return -1. if the value cannot be found
func LastIndexOfFloat32 ¶
LastIndexOfFloat32 gets the index at which the first occurrence of an float32 value is found in array or return -1 if the value cannot be found
func LastIndexOfFloat64 ¶
LastIndexOfFloat64 gets the index at which the first occurrence of an float64 value is found in array or return -1 if the value cannot be found
func LastIndexOfInt ¶
LastIndexOfInt gets the index at which the first occurrence of an int value is found in array or return -1 if the value cannot be found
func LastIndexOfInt32 ¶
LastIndexOfInt32 gets the index at which the first occurrence of an int32 value is found in array or return -1 if the value cannot be found
func LastIndexOfInt64 ¶
LastIndexOfInt64 gets the index at which the first occurrence of an int64 value is found in array or return -1 if the value cannot be found
func LastIndexOfString ¶
LastIndexOfString gets the index at which the first occurrence of a string value is found in array or return -1 if the value cannot be found
func LastIndexOfUInt ¶
LastIndexOfUInt gets the index at which the first occurrence of an uint value is found in array or return -1 if the value cannot be found
func LastIndexOfUInt32 ¶
LastIndexOfUInt32 gets the index at which the first occurrence of an uint32 value is found in array or return -1 if the value cannot be found
func LastIndexOfUInt64 ¶
LastIndexOfUInt64 gets the index at which the first occurrence of an uint64 value is found in array or return -1 if the value cannot be found
func Map ¶
Map returns a copy of the string `s` with all its characters modified according to the `mapping` function. If `mapping` returns a negative value, the character is dropped from the string with no replacement.
Example:
rot13 := func(r rune) rune { switch { case r >= 'A' && r <= 'Z': return 'A' + (r-'A'+13)%26 case r >= 'a' && r <= 'z': return 'a' + (r-'a'+13)%26 } return r } fmt.Println(strings.Map(rot13, "'Twas brillig and the slithy gopher...")) out: 'Gjnf oevyyvt naq gur fyvgul tbcure...
func Max ¶
func Max(x interface{}) interface{}
Max return the maximum value of `x`, the type of x is one of []int, []float32, []float64, []string. If x is empty, and type is one of []int, []float32 and []float64, will return 0. If x is empty, and type is one of []string, will return "".
func MaxFloat32s ¶
MaxFloat32s will return maximum value of `x...`. If x is empty, and return 0.
func MaxFloat64s ¶
MaxFloat64s will return maximum value of `x...`. If x is empty, and return 0.
func MaxStrings ¶
MaxStrings will return maximum value of `x...`. Compares iterms using code point.
func Min ¶
func Min(x interface{}) interface{}
Min return the minimum value of `x`, the type of x is one of []int, []float32, []float64, []string. If x is empty, and type is one of []int, []float32 and []float64, will return 0. If x is empty, and type is one of []string, will return "".
func MinFloat32s ¶
MinFloat32s will return minimum value of `x...`. If x is empty, and return 0.
func MinFloat64s ¶
MinFloat64s will return minimum value of `x...`. If x is empty, and return 0.
func MinStrings ¶
MinStrings will return minimum value of `x...`. Compares iterms using code point If x is empty, and return "".
func NewBuffer ¶
NewBuffer creates and initializes a new Buffer using buf as its initial contents. The new Buffer takes ownership of buf, and the caller should not use buf after this call. NewBuffer is intended to prepare a Buffer to read existing data. It can also be used to set the initial size of the internal buffer for writing. To do that, buf should have the desired capacity but a length of zero.
In most cases, new(Buffer) (or just declaring a Buffer variable) is sufficient to initialize a Buffer.
func NewBufioReader ¶
NewReader returns a new Reader whose buffer has the default size.
func NewStringBuilder ¶
NewStringBuilder will return `*strings.Builder`
A Builder is used to efficiently build a string using Write methods. It minimizes memory copying. The zero value is ready to use. Do not copy a non-zero Builder.
func NewStringReader ¶
NewStringReader returns a new Reader reading from s. It is similar to bytes.NewBufferString but more efficient and read-only.
func NumberBanner ¶
NumberBanner return numbers' string with length `width`
Example:
NumberBanner(11) return "01234567890"
func PaddingBytes ¶
PaddingBytes add pad-prefix in every line('\n') of []byte
func PaddingString ¶
PaddingString add pad-prefix in every line of string
func RandomString ¶
RandomString returns a random string with a fixed length
func Repeat ¶
Repeat returns a new string consisting of count copies of the string `s`.
It panics if `count` is negative or if the result of (`len(s) * count`) overflows.
Example:
fmt.Println("ba" + strings.Repeat("na", 2)) out: banana
func Replace ¶
Replace returns a copy of the string `s` with the first `n` 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. If `n < 0`, there is no limit on the number of replacements.
Example:
fmt.Println(strings.Replace("oink oink oink", "k", "ky", 2)) fmt.Println(strings.Replace("oink oink oink", "oink", "moo", -1)) out: oinky oinky oink moo moo moo
func ReplaceAll ¶
ReplaceAll 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.
Example:
fmt.Println(strings.ReplaceAll("oink oink oink", "oink", "moo")) out: moo moo moo
func ReverseByte ¶
ReverseByte reverse the string `s` based on `byte`
func ReverseFloat32 ¶
ReverseFloat32 reverses an array of float32
func ReverseFloat64 ¶
ReverseFloat64 reverses an array of float64
func ReverseStrings ¶
ReverseStrings reverses an array of string
func ReverseUInt32 ¶
ReverseUInt32 reverses an array of uint32
func ReverseUInt64 ¶
ReverseUInt64 reverses an array of uint64
func RuneWidth ¶
RuneWidth returns the number of cells in r. See http://www.unicode.org/reports/tr11/
func SetLoggerFieldsOrder ¶
func SetLoggerFieldsOrder(fields []string)
SetLoggerFieldsOrder set `nestedFormatter.FieldsOrder`
func ShuffleFloat32 ¶
ShuffleFloat32 creates an array of float32 shuffled values using Fisher–Yates algorithm
func ShuffleFloat64 ¶
ShuffleFloat64 creates an array of float64 shuffled values using Fisher–Yates algorithm
func ShuffleInt ¶
ShuffleInt creates an array of int shuffled values using Fisher–Yates algorithm
func ShuffleInt32 ¶
ShuffleInt32 creates an array of int32 shuffled values using Fisher–Yates algorithm
func ShuffleInt64 ¶
ShuffleInt64 creates an array of int64 shuffled values using Fisher–Yates algorithm
func ShuffleString ¶
ShuffleString creates an array of string shuffled values using Fisher–Yates algorithm
func ShuffleUInt ¶
ShuffleUInt creates an array of int shuffled values using Fisher–Yates algorithm
func ShuffleUInt32 ¶
ShuffleUInt32 creates an array of uint32 shuffled values using Fisher–Yates algorithm
func ShuffleUInt64 ¶
ShuffleUInt64 creates an array of uint64 shuffled values using Fisher–Yates algorithm
func Split ¶
Split slices s into all substrings separated by sep and returns a slice of the substrings between those separators.
If s does not contain sep and sep is not empty, Split returns a slice of length 1 whose only element is s.
If sep is empty, Split splits after each UTF-8 sequence. If both s and sep are empty, Split returns an empty slice.
It is equivalent to SplitN with a count of -1.
Example
package main import ( "fmt" "strings" ) func main() { fmt.Printf("%q\n", strings.Split("a,b,c", ",")) // ["a" "b" "c"] fmt.Printf("%q\n", strings.Split("a man a plan a canal panama", "a ")) // ["" "man " "plan " "canal panama"] fmt.Printf("%q\n", strings.Split(" xyz ", "")) // [" " "x" "y" "z" " "] fmt.Printf("%q\n", strings.Split("", "Bernardo O'Higgins")) // [""] }
func SplitAfter ¶
SplitAfter slices s into all substrings after each instance of sep and returns a slice of those substrings.
If s does not contain sep and sep is not empty, SplitAfter returns a slice of length 1 whose only element is s.
If sep is empty, SplitAfter splits after each UTF-8 sequence. If both s and // sep are empty, SplitAfter returns an empty slice.
It is equivalent to SplitAfterN with a count of -1.
Example
package main import ( "fmt" "strings" ) func main() { fmt.Printf("%q\n", strings.SplitAfter("a,b,c", ",")) // ["a," "b," "c"] }
func SplitAfterN ¶
SplitAfterN slices s into substrings after each instance of sep and returns a slice of those substrings.
The count determines the number of substrings to return:
n > 0: at most n substrings; the last substring will be the unsplit remainder. n == 0: the result is nil (zero substrings) n < 0: all substrings
Edge cases for s and sep (for example, empty strings) are handled as described in the documentation for SplitAfter.
Example ¶
package main
import (
"fmt" "strings"
)
func main() { fmt.Printf("%q\n", strings.SplitAfterN("a,b,c", ",", 2)) // ["a," "b,c"] }
func SplitN ¶
SplitN slices s into substrings separated by sep and returns a slice of the substrings between those separators.
The count determines the number of substrings to return:
n > 0: at most n substrings; the last substring will be the unsplit remainder. n == 0: the result is nil (zero substrings) n < 0: all substrings
Edge cases for s and sep (for example, empty strings) are handled as described in the documentation for Split.
Example
package main import ( "fmt" "strings" ) func main() { fmt.Printf("%q\n", strings.SplitN("a,b,c", ",", 2)) // ["a" "b,c"] z := strings.SplitN("a,b,c", ",", 0) fmt.Printf("%q (nil = %v)\n", z, z == nil) //[] (nil = true) }
func StringWidth ¶
StringWidth will return width as you can see (the numbers of placeholders on terminal)
func Sum ¶
func Sum(x interface{}) interface{}
Sum will return summation of []int, []float32, []flot64, []string. If the type of `x` is not one of []int, []float32, []flot64 and []string, then return `nil` If `x` is []string, will return concatenation using `strings.Join(a,"")`.
func SumFloat32s ¶
SumFloat32s will return summation of []float32
func SumFloat64s ¶
SumFloat64s will return summation of []float64
func SumStrings ¶
SumStrings will return concatenation of []string using strings.Join(a, "")
func Title ¶
Title returns a copy of the string `s` with all Unicode letters that begin words mapped to their Unicode title case.
BUG(rsc): The rule Title uses for word boundaries does not handle Unicode punctuation properly.
Example:
Compare this example to the ToTitle example. fmt.Println(strings.Title("her royal highness")) fmt.Println(strings.Title("loud noises")) fmt.Println(strings.Title("хлеб")) out: Her Royal Highness Loud Noises Хлеб
func ToLower ¶
ToLower returns s with all Unicode letters mapped to their lower case.
Example:
fmt.Println(strings.ToLower("Gopher")) out: gopher
func ToTitle ¶
ToTitle returns a copy of the string `s` with all Unicode letters mapped to their Unicode title case.
Example:
Compare this example to the Title example. fmt.Println(strings.ToTitle("her royal highness")) fmt.Println(strings.ToTitle("loud noises")) fmt.Println(strings.ToTitle("хлеб")) out: HER ROYAL HIGHNESS LOUD NOISES ХЛЕБ
func ToUpper ¶
ToUpper returns `s` with all Unicode letters mapped to their upper case.
Example:
fmt.Println(strings.ToUpper("Gopher")) out: GOPHER
func Trim ¶
Trim returns a slice of the string `s` with all leading and trailing Unicode code points contained in `cutset` removed.
func TrimFrontEndSpaceLine ¶
TrimFrontEndSpaceLine trim the front and end empty line of `content` and return
func TrimFunc ¶
TrimFunc returns a slice of the string `s` with all leading and trailing Unicode code points `c` satisfying `f(c)` removed.
Example:
fmt.Print(strings.TrimFunc("¡¡¡Hello, Gophers!!!", func(r rune) bool { return !unicode.IsLetter(r) && !unicode.IsNumber(r)})) out: Hello, Gophers
func TrimLeft ¶
TrimLeft returns a slice of the string `s` with all leading Unicode code points contained in `cutset` removed.
To remove a `prefix`, use `TrimPrefix` instead.
Example:
fmt.Print(strings.TrimLeft("¡¡¡Hello, Gophers!!!", "!¡")) out: Hello, Gophers!!!
func TrimLeftFunc ¶
TrimLeftFunc returns a slice of the string `s` with all leading Unicode code points `c` satisfying `f(c)` removed.
Example:
fmt.Print(strings.TrimLeftFunc("¡¡¡Hello, Gophers!!!", func(r rune) bool {return !unicode.IsLetter(r) && !unicode.IsNumber(r)})) out: Hello, Gophers!!!
func TrimPrefix ¶
TrimPrefix returns `s` without the provided leading prefix string. If `s` doesn't start with `prefix`, `s` is returned unchanged.
Example:
var s = "¡¡¡Hello, Gophers!!!" s = strings.TrimPrefix(s, "¡¡¡Hello, ") s = strings.TrimPrefix(s, "¡¡¡Howdy, ") fmt.Print(s) out: Gophers!!!
func TrimRight ¶
TrimRight returns a slice of the string `s`, with all trailing Unicode code points contained in cutset removed.
To remove a `suffix`, use `TrimSuffix` instead.
Example:
fmt.Print(strings.TrimRight("¡¡¡Hello, Gophers!!!", "!¡"))
out: ¡¡¡Hello, Gophers
func TrimRightFunc ¶
TrimRightFunc returns a slice of the string `s` with all trailing Unicode code points `c` satisfying `f(c)` removed.
Example:
fmt.Print(strings.TrimRightFunc("¡¡¡Hello, Gophers!!!", func(r rune) bool {return !unicode.IsLetter(r) && !unicode.IsNumber(r)}))
out: ¡¡¡Hello, Gophers
func TrimSpace ¶
TrimSpace returns a slice of the string `s`, with all leading and trailing white space removed, as defined by Unicode.
Example:
fmt.Println(strings.TrimSpace(" \t\n Hello, Gophers \n\t\r\n")) out: Hello, Gophers
func TrimSuffix ¶
TrimSuffix returns `s` without the provided trailing `suffix` string. If `s` doesn't end with suffix, `s` is returned unchanged.
Example:
var s = "¡¡¡Hello, Gophers!!!" s = strings.TrimSuffix(s, ", Gophers!!!") s = strings.TrimSuffix(s, ", Marmots!!!") out: ¡¡¡Hello
func Utf8ToBig5String ¶
Utf8ToBig5String encodes UTF8 to Big5
func Utf8ToGbkString ¶
Utf8ToGbkString encodes UTF8 to GBK
func WrapToSlice ¶
WrapToSlice return string slice wrapped with w cells
Types ¶
type StrChain ¶
type StrChain struct {
// contains filtered or unexported fields
}
StrChain contains all tools which can be chained.
func (*StrChain) Big5ToUtf8String ¶
Big5ToUtf8String packs `Big5ToUtf8String(s string)`
func (*StrChain) Bytes ¶
Bytes will convert the string t.v to []byte
Example:
b := StrChain{"ABC€"} fmt.Println(b.Bytes()) // [65 66 67 226 130 172]
func (*StrChain) ContainsAny ¶
ContainsAny return `ContainsAny(t.v, chars)`
func (*StrChain) ContainsRune ¶
ContainsAny return ContainsRune(t.v, r) bool
func (*StrChain) CountPlaceHolder ¶
CountPlaceHolder return `nHan` and `nASCII`
`nHan`: number of occupied space in screen for han-character `nASCII`: number of occupied space in screen for ASCII-character
func (*StrChain) FieldsFunc ¶
FieldsFunc return FieldsFunc(t.v, f)
func (*StrChain) GbkToUtf8String ¶
GbkToUtf8String packs `GbkToUtf8String(s string)`
func (*StrChain) GetAbbrString ¶
GetAbbrString get a abbreviation of `StrChain.sCollection.s` and save to `StrChain.sCollection.s`
`maxlen`: maimium length of the abbreviation `conSymbole`: tailing symbol of the abbreviation
func (*StrChain) HasChineseChar ¶
HasChineseChar return true for that `str` include chinese character
Example:
HasChineseChar("abc 中文") return true HasChineseChar("abccefgh") return false
func (*StrChain) IsEqualString ¶
IsEqualString packs `IsEqualString(a, b string, ignoreCase bool) bool`
func (*StrChain) LastIndexAny ¶
LastIndexAny return LastIndexAny(t.v, chars) int
func (*StrChain) LastIndexByte ¶
LastIndexByte return LastIndexByte(t.v, c) int
func (*StrChain) LastIndexFunc ¶
LastIndexFunc return LastIndexFunc(t.v, f) int
func (*StrChain) Map ¶
Map packs `Map(mapping func(rune) rune, s string)`
set `StrChain.S` to the result
func (*StrChain) NewStrChain ¶
NewStrChain return a instance of `StrChain` and return `*StrChain`
func (*StrChain) NumberBanner ¶
NumberBanner return numbers' string with length of `StrChain.sCollection.s`
Example:
StrChain.sCollection.s = "Text中文 Collection" nh, na := CountPlaceHolder("Text中文 Collection") --> nh=4, na=15 --> length = nh + na = 19 NumberBanner() return "12345678901"
func (*StrChain) Replace ¶
Replace packs `Replace(s, old, new string, n int)`
set `StrChain.S` to the result
func (*StrChain) ReplaceAll ¶
ReplaceAll packs `ReplaceAll(s, old, new string)`
set `StrChain.S` to the result
func (*StrChain) Reverse ¶
Reverse packs `Reverse(s string)` based on `rune`
set `StrChain.S` to the result
func (*StrChain) ReverseByte ¶
ReverseByte packs `ReverseByte(s string)` based on `byte`
set `StrChain.S` to the result
func (*StrChain) Runes ¶
Runes will convert the string t.v to []rune
Example:
r := StrChain{"ABC€"} fmt.Println(r.Runes()) // [65 66 67 8364] fmt.Printf("%U\n", r.Rune()) // [U+0041 U+0042 U+0043 U+20AC]
func (*StrChain) SplitAfter ¶
Split return Split(t.v, sep) []string
func (*StrChain) SplitAfterN ¶
Split return Split(t.v, sep) []string
func (*StrChain) StringWidth ¶
StringWidth will return width as you can see (the numbers of placeholders on terminal)
func (*StrChain) TrimFrontEndSpaceLine ¶
TrimFrontEndSpaceLine packs `TrimFrontEndSpaceLine(content string) string`
func (*StrChain) TrimFunc ¶
TrimFunc packs `TrimFunc(s string, f func(rune) bool)`
set `StrChain.S` to the result
func (*StrChain) TrimLeft ¶
TrimLeft packs `TrimLeft(s, cutset string)`
set `StrChain.S` to the result
func (*StrChain) TrimLeftFunc ¶
TrimLeftFunc packs `TrimLeftFunc(s string, f func(rune) bool)`
set `StrChain.S` to the result
func (*StrChain) TrimPrefix ¶
TrimPrefix packs `TrimPrefix(s, prefix string)`
set `StrChain.S` to the result
func (*StrChain) TrimRight ¶
TrimRight packs `TrimRight(s, cutset string)`
set `StrChain.S` to the result
func (*StrChain) TrimRightFunc ¶
TrimRightFunc packs `TrimRightFunc(s string, f func(rune) bool)`
set `StrChain.S` to the result
func (*StrChain) TrimSuffix ¶
TrimSuffix packs `TrimSuffix(s, suffix string)`
set `StrChain.S` to the result
func (*StrChain) Utf8ToBig5String ¶
Utf8ToBig5String packs `Utf8ToBig5String(s string)`
func (*StrChain) Utf8ToGbkString ¶
Utf8ToGbkString packs `Utf8ToGbkString(s string)`
type TableFormat ¶
type TableFormat struct { Fields []string LenFields []int Aligns []Align Colors []*color.Color FieldsColorString []string Padding string Sep string TopChar string MiddleChar string BottomChar string IsWrapped bool IsColorful bool // chdEven *color.Color // chdOdd *color.Color XAttributeSymbol string XAttributeSymbol2 string // contains filtered or unexported fields }
TableFormat define the format used to print out
Elements:
`Fields []string{}`, string list of heading row `LenFields []int{}`, length of every field of heading row `Aligns []Align{}` : , `Padding string`: paddign string befor every row, default "", `Sep string` : sepperating string between fields `TopChar string`: character of top sepperating row, default "=", `MiddleChar string`: character of middle sepperating row , default "-", `BottomChar string`: character of bottom sepperating row, default "=",
func NewTableFormat ¶
func NewTableFormat() *TableFormat
NewTableFormat return a instance of TableFormat
func (*TableFormat) NFields ¶
func (t *TableFormat) NFields() int
NFields will return number of TableFormat.Fields
func (*TableFormat) Prepare ¶
func (t *TableFormat) Prepare(w io.Writer)
Prepare initialize `TableFormat`
func (*TableFormat) PrintEnd ¶
func (t *TableFormat) PrintEnd()
PrintEnd print end-section into `t.writer`
func (*TableFormat) PrintMiddleSepLine ¶
func (t *TableFormat) PrintMiddleSepLine()
PrintMiddleSepLine print middle sepperating line using `MiddleChar`
func (*TableFormat) PrintRow ¶
func (t *TableFormat) PrintRow(rows ...interface{})
PrintRow print row into `t.writer`
func (*TableFormat) PrintSart ¶
func (t *TableFormat) PrintSart() error
PrintSart print out head-section in `t.Writer`
func (*TableFormat) SetAfterMessage ¶
func (t *TableFormat) SetAfterMessage(msg string)
SetAfterMessage set message to show after table
func (*TableFormat) SetBeforeMessage ¶
func (t *TableFormat) SetBeforeMessage(msg string)
SetBeforeMessage set message to show before table
func (*TableFormat) SetWrapFields ¶
func (t *TableFormat) SetWrapFields()
SetWrapFields set true to TableFormat.IsWrapped
type TextBuilder ¶
type TextBuilder struct {
Text string
}
TextBuilder contains all tools which can be chained.
func (*TextBuilder) Big5ToUtf8String ¶
func (t *TextBuilder) Big5ToUtf8String() (TextTools, error)
Big5ToUtf8String packs `Big5ToUtf8String(s string)`
func (*TextBuilder) Contains ¶
func (t *TextBuilder) Contains(substr string) bool
Contains return `Contains(t.Text, substr)`
func (*TextBuilder) ContainsAny ¶
func (t *TextBuilder) ContainsAny(chars string) bool
ContainsAny return `ContainsAny(t.Text, chars)`
func (*TextBuilder) ContainsRune ¶
func (t *TextBuilder) ContainsRune(r rune) bool
ContainsAny return ContainsRune(t.Text, r) bool
func (*TextBuilder) CountPlaceHolder ¶
func (t *TextBuilder) CountPlaceHolder() (nHan int, nASCII int)
CountPlaceHolder return `nHan` and `nASCII`
`nHan`: number of occupied space in screen for han-character `nASCII`: number of occupied space in screen for ASCII-character
func (*TextBuilder) EqualFold ¶
func (t *TextBuilder) EqualFold(s string) bool
EqualFold return EqualFold(t.Text,, t) bool
func (*TextBuilder) FieldsFunc ¶
func (t *TextBuilder) FieldsFunc(f func(rune) bool) []string
FieldsFunc return FieldsFunc(t.Text, f)
func (*TextBuilder) GbkToUtf8String ¶
func (t *TextBuilder) GbkToUtf8String() (TextTools, error)
GbkToUtf8String packs `GbkToUtf8String(s string)`
func (*TextBuilder) GetAbbrString ¶
func (t *TextBuilder) GetAbbrString(maxlen int, contSymbol string) TextTools
GetAbbrString get a abbreviation of `TextBuilder.TextCollection.Text` and save to `TextBuilder.TextCollection.Text`
`maxlen`: maimium length of the abbreviation `conSymbole`: tailing symbol of the abbreviation
func (*TextBuilder) GetText ¶
func (t *TextBuilder) GetText() string
GetText return `TextBuilder.TextCollection.Text`
func (*TextBuilder) HasChineseChar ¶
func (t *TextBuilder) HasChineseChar() bool
HasChineseChar return true for that `str` include chinese character
Example:
HasChineseChar("abc 中文") return true HasChineseChar("abccefgh") return false
func (*TextBuilder) HasPrefix ¶
func (t *TextBuilder) HasPrefix(prefix string) bool
HasPrefix return `HasPrefix(t.Text, prefix)`
func (*TextBuilder) HasSuffix ¶
func (t *TextBuilder) HasSuffix(suffix string) bool
HasSuffix return `HasSuffix(t.Text, Suffix)`
func (*TextBuilder) Index ¶
func (t *TextBuilder) Index(substr string) int
Index return Index(t.Text, substr) int
func (*TextBuilder) IndexAny ¶
func (t *TextBuilder) IndexAny(chars string) int
IndexAny return IndexAny(t.Text, chars) int
func (*TextBuilder) IndexByte ¶
func (t *TextBuilder) IndexByte(c byte) int
IndexByte return IndexByte(t.Text, c) int
func (*TextBuilder) IndexFunc ¶
func (t *TextBuilder) IndexFunc(f func(rune) bool) int
IndexFunc return IndexFunc(t.Text, f) int
func (*TextBuilder) IndexRune ¶
func (t *TextBuilder) IndexRune(r rune) int
IndexRune return IndexRune(t.Text, r) int
func (*TextBuilder) IsEqualString ¶
func (t *TextBuilder) IsEqualString(b string, ignoreCase bool) bool
IsEqualString packs `IsEqualString(a, b string, ignoreCase bool) bool`
func (*TextBuilder) LastIndex ¶
func (t *TextBuilder) LastIndex(substr string) int
LastIndex return LastIndex(t.Text, substr) int
func (*TextBuilder) LastIndexAny ¶
func (t *TextBuilder) LastIndexAny(chars string) int
LastIndexAny return LastIndexAny(t.Text, chars) int
func (*TextBuilder) LastIndexByte ¶
func (t *TextBuilder) LastIndexByte(c byte) int
LastIndexByte return LastIndexByte(t.Text, c) int
func (*TextBuilder) LastIndexFunc ¶
func (t *TextBuilder) LastIndexFunc(f func(rune) bool) int
LastIndexFunc return LastIndexFunc(t.Text, f) int
func (*TextBuilder) Map ¶
func (t *TextBuilder) Map(mapping func(rune) rune) TextTools
Map packs `Map(mapping func(rune) rune, s string)`
set `TextCollection.Text` to the result
func (*TextBuilder) NewTextBuilder ¶
func (t *TextBuilder) NewTextBuilder(s string) TextTools
NewTextBuilder return a instance of `TextBuilder` and return `TextTools`
func (*TextBuilder) NumberBanner ¶
func (t *TextBuilder) NumberBanner() TextTools
NumberBanner return numbers' string with length of `TextBuilder.TextCollection.Text`
Example:
TextBuilder.TextCollection.Text = "Text中文 Collection" nh, na := CountPlaceHolder("Text中文 Collection") --> nh=4, na=15 --> length = nh + na = 19 NumberBanner() return "12345678901"
func (*TextBuilder) Repeat ¶
func (t *TextBuilder) Repeat(count int) TextTools
Repeat packs `Repeat(s string, count int)`
set `TextCollection.Text` to the result
func (*TextBuilder) Replace ¶
func (t *TextBuilder) Replace(old, new string, n int) TextTools
Replace packs `Replace(s, old, new string, n int)`
set `TextCollection.Text` to the result
func (*TextBuilder) ReplaceAll ¶
func (t *TextBuilder) ReplaceAll(old, new string) TextTools
ReplaceAll packs `ReplaceAll(s, old, new string)`
set `TextCollection.Text` to the result
func (*TextBuilder) Reverse ¶
func (t *TextBuilder) Reverse() TextTools
Reverse packs `Reverse(s string)`
set `TextCollection.Text` to the result
func (*TextBuilder) SetText ¶
func (t *TextBuilder) SetText(txt string) TextTools
SetText set `TextBuilder.Text` to `txt`
func (*TextBuilder) Split ¶
func (t *TextBuilder) Split(sep string) []string
Split return Split(t.Text, sep) []string
func (*TextBuilder) SplitAfter ¶
func (t *TextBuilder) SplitAfter(sep string) []string
Split return Split(t.Text, sep) []string
func (*TextBuilder) SplitAfterN ¶
func (t *TextBuilder) SplitAfterN(sep string, n int) []string
Split return Split(t.Text, sep) []string
func (*TextBuilder) SplitN ¶
func (t *TextBuilder) SplitN(sep string, n int) []string
Split return Split(t.Text, sep) []string
func (*TextBuilder) String ¶
func (t *TextBuilder) String() string
String return `TextBuilder.TextCollection.Text`
func (*TextBuilder) Title ¶
func (t *TextBuilder) Title() TextTools
Title returns packs `Title(s string)`
set `TextCollection.Text` to the result
func (*TextBuilder) ToLower ¶
func (t *TextBuilder) ToLower() TextTools
ToLower packs ` ToLower(s string)`
set `TextCollection.Text` to the result
func (*TextBuilder) ToTitle ¶
func (t *TextBuilder) ToTitle() TextTools
ToTitle packs `ToTitle(s string)`
set `TextCollection.Text` to the result
func (*TextBuilder) ToUpper ¶
func (t *TextBuilder) ToUpper() TextTools
ToUpper packs `ToUpper(s string)`
set `TextCollection.Text` to the result
func (*TextBuilder) Trim ¶
func (t *TextBuilder) Trim(cutset string) TextTools
Trim packs `Trim(s, cutset)`
set `TextCollection.Text` to the result
func (*TextBuilder) TrimBOM ¶
func (t *TextBuilder) TrimBOM() TextTools
TrimBOM packs `TrimBOM(line string) string`
func (*TextBuilder) TrimFrontEndSpaceLine ¶
func (t *TextBuilder) TrimFrontEndSpaceLine() TextTools
TrimFrontEndSpaceLine packs `TrimFrontEndSpaceLine(content string) string`
func (*TextBuilder) TrimFunc ¶
func (t *TextBuilder) TrimFunc(f func(rune) bool) TextTools
TrimFunc packs `TrimFunc(s string, f func(rune) bool)`
set `TextCollection.Text` to the result
func (*TextBuilder) TrimLeft ¶
func (t *TextBuilder) TrimLeft(cutset string) TextTools
TrimLeft packs `TrimLeft(s, cutset string)`
set `TextCollection.Text` to the result
func (*TextBuilder) TrimLeftFunc ¶
func (t *TextBuilder) TrimLeftFunc(f func(rune) bool) TextTools
TrimLeftFunc packs `TrimLeftFunc(s string, f func(rune) bool)`
set `TextCollection.Text` to the result
func (*TextBuilder) TrimPrefix ¶
func (t *TextBuilder) TrimPrefix(prefix string) TextTools
TrimPrefix packs `TrimPrefix(s, prefix string)`
set `TextCollection.Text` to the result
func (*TextBuilder) TrimRight ¶
func (t *TextBuilder) TrimRight(cutset string) TextTools
TrimRight packs `TrimRight(s, cutset string)`
set `TextCollection.Text` to the result
func (*TextBuilder) TrimRightFunc ¶
func (t *TextBuilder) TrimRightFunc(f func(rune) bool) TextTools
TrimRightFunc packs `TrimRightFunc(s string, f func(rune) bool)`
set `TextCollection.Text` to the result
func (*TextBuilder) TrimSpace ¶
func (t *TextBuilder) TrimSpace() TextTools
TrimSpace packs `TrimSpace(s string)`
set `TextCollection.Text` to the result
func (*TextBuilder) TrimSuffix ¶
func (t *TextBuilder) TrimSuffix(suffix string) TextTools
TrimSuffix packs `TrimSuffix(s, suffix string)`
set `TextCollection.Text` to the result
func (*TextBuilder) Utf8ToBig5String ¶
func (t *TextBuilder) Utf8ToBig5String() (TextTools, error)
Utf8ToBig5String packs `Utf8ToBig5String(s string)`
func (*TextBuilder) Utf8ToGbkString ¶
func (t *TextBuilder) Utf8ToGbkString() (TextTools, error)
Utf8ToGbkString packs `Utf8ToGbkString(s string)`
type TextTools ¶
type TextTools interface { GetAbbrString(maxlen int, contSymbol string) TextTools Map(mapping func(rune) rune) TextTools NumberBanner() TextTools Repeat(count int) TextTools Replace(old, new string, n int) TextTools ReplaceAll(old, new string) TextTools Reverse() TextTools SetText(txt string) TextTools Title() TextTools ToLower() TextTools ToTitle() TextTools ToUpper() TextTools Trim(cutset string) TextTools TrimFunc(f func(rune) bool) TextTools TrimLeft(cutset string) TextTools TrimLeftFunc(f func(rune) bool) TextTools TrimPrefix(prefix string) TextTools TrimRight(cutset string) TextTools TrimRightFunc(f func(rune) bool) TextTools TrimSpace() TextTools TrimSuffix(suffix string) TextTools TrimBOM() TextTools TrimFrontEndSpaceLine() TextTools Big5ToUtf8String() (TextTools, error) Utf8ToBig5String() (TextTools, error) GbkToUtf8String() (TextTools, error) Utf8ToGbkString() (TextTools, error) CountPlaceHolder() (nHan int, nASCII int) Contains(substr string) bool ContainsAny(chars string) bool ContainsRune(r rune) bool EqualFold(t string) bool Fields() []string FieldsFunc(f func(rune) bool) []string Index(substr string) int IndexAny(chars string) int IndexByte(c byte) int IndexFunc(f func(rune) bool) int IndexRune(r rune) int LastIndex(substr string) int LastIndexAny(chars string) int LastIndexByte(c byte) int LastIndexFunc(f func(rune) bool) int Split(sep string) []string SplitN(sep string, n int) []string SplitAfter(sep string) []string SplitAfterN(sep string, n int) []string GetText() string HasChineseChar() bool HasPrefix(prefix string) bool HasSuffix(suffix string) bool IsEqualString(b string, ignoreCase bool) bool }
TextTools is the collections of tools of text
Notes ¶
Bugs ¶
The rule Title uses for word boundaries does not handle Unicode punctuation properly.
Example:
Compare this example to the ToTitle example. fmt.Println(strings.Title("her royal highness")) fmt.Println(strings.Title("loud noises")) fmt.Println(strings.Title("хлеб")) out: Her Royal Highness Loud Noises Хлеб
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
3rd-party
|
|
godirwalk/examples/find-fast
* find-fast * * Walks a file system hierarchy using this library.
|
* find-fast * * Walks a file system hierarchy using this library. |
godirwalk/examples/remove-empty-directories
* remove-empty-directories * * Walks a file system hierarchy and removes all directories with no children.
|
* remove-empty-directories * * Walks a file system hierarchy and removes all directories with no children. |
godirwalk/examples/sizes
* sizes * * Walks a file system hierarchy and prints sizes of file system objects, * recursively printing sizes of directories.
|
* sizes * * Walks a file system hierarchy and prints sizes of file system objects, * recursively printing sizes of directories. |
godirwalk/examples/walk-fast
* walk-fast * * Walks a file system hierarchy using this library.
|
* walk-fast * * Walks a file system hierarchy using this library. |
godirwalk/examples/walk-stdlib
* walk-fast * * Walks a file system hierarchy using the standard library.
|
* walk-fast * * Walks a file system hierarchy using the standard library. |
treeprint
Package treeprint provides a simple ASCII tree composing tool.
|
Package treeprint provides a simple ASCII tree composing tool. |
Package cast provides easy and safe casting in Go.
|
Package cast provides easy and safe casting in Go. |
Package bytefmt contains helper methods and constants for converting to and from a human-readable byte format.
|
Package bytefmt contains helper methods and constants for converting to and from a human-readable byte format. |