str

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InArray

func InArray(needle string, haystack []string) bool

InArray checks if a string is in a string array.

Example:

InArray("abc", []string{"abc", "def"}) // true

func Is

func Is(pattern, value string) bool

Is returns true if the value matches the pattern. The pattern can contain the wildcard character *.

Example:

Is("*.example.com", "www.example.com") // true
Is("*.example.com", "example.com") // false

func Md5

func Md5(s string) string

Md5 returns the md5 hash of a string.

Example:

Md5("abc") // 900150983cd24fb0d6963f7d28e17f72

func RandomString

func RandomString(length int) string

RandomString returns a random string with the specified length.

Example:

RandomString(10) // "qujrlkhyqr"

func StrShuffle

func StrShuffle(s string) string

StrShuffle returns a string with its characters in random order.

Example:

StrShuffle("abc") // "bca"

func Strpos

func Strpos(haystack, needle string) int

Strpos returns the position of the first occurrence of a substring in a string.

Example:

Strpos("abc", "b") // 1

func Strrev

func Strrev(s string) string

Strrev returns a string with its characters in reverse order.

Example:

Strrev("abc") // "cba"

func Strrpos

func Strrpos(haystack, needle string) int

Strrpos returns the position of the last occurrence of a substring in a string.

Example:

Strrpos("abc", "b") // 1

func Strtr

func Strtr(s, from, to string) string

Strtr replaces all occurrences of the search string with the replacement string.

Example:

Strtr("aabbcc", "a", "b") // "bbbbcc"

Types

type AtoiRes

type AtoiRes struct {
	// contains filtered or unexported fields
}

AtoiRes is the result of Atoi.

func Atoi

func Atoi(s string) AtoiRes

Atoi converts a string to an int.

func (AtoiRes) Err

func (r AtoiRes) Err() error

Err returns the error of the result.

func (AtoiRes) IsErr

func (r AtoiRes) IsErr() bool

IsErr returns true if the result is an error.

func (AtoiRes) IsOk

func (r AtoiRes) IsOk() bool

IsOk returns true if the result is ok.

func (AtoiRes) Val

func (r AtoiRes) Val() int

Val returns the value of the result.

Jump to

Keyboard shortcuts

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