stringx

package
v0.7.14 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddURLSchema

func AddURLSchema(url string, scheme string) string

AddURLSchema if url do not have scheme then add one sheme should have ://

func BytesToString

func BytesToString(b []byte) string

BytesToString ...

func Camel2Case added in v0.5.2

func Camel2Case(name string) string

Camel2Case ...

func Case2Camel added in v0.5.2

func Case2Camel(name string) string

Case2Camel ...

func Compress

func Compress(str string) string

Compress for trim space in string

func Dedup

func Dedup(s []string) []string

Dedup remove duplicate element in slice

func EncodePEM

func EncodePEM(certPEM []byte) (string, error)

EncodePEM encode a pem byte array to a string

func Format added in v0.7.6

func Format(str string, data map[string]any) string

Format ... usage: res := Format("this is a {{.name}}, {{.age}} years old", map[string]any{"name": "Bob", "age": 10})

func GenRankStr

func GenRankStr(n int) string

GenRankStr gen random string 生成随机字符串 param n: string length 字符串长度

func GenRankStrLowercase

func GenRankStrLowercase(n int) string

GenRankStrLowercase gen random string with lowercase param n: string length

func Has

func Has(list []string, element string) bool

Has represent if a element is in the list

func Lcfirst added in v0.5.2

func Lcfirst(str string) string

Lcfirst ...

func Pointer

func Pointer(input string) *string

Pointer return a address of a string

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes ...

func ToMap

func ToMap(data []string) map[string]struct{}

ToMap transfer a string slice to a map

func TrimField added in v0.6.1

func TrimField(ptr any)

TrimField trim struct string field, ptr must be a struct pointer

func URLJoin

func URLJoin(base string, paths ...string) string

URLJoin like strings.Join but for url path

func Ucfirst added in v0.5.2

func Ucfirst(str string) string

Ucfirst ...

func UnicodeToZH added in v0.5.4

func UnicodeToZH(raw string) (string, error)

UnicodeToZH turn unitcode into Chinese

func ZHToUnicode added in v0.5.4

func ZHToUnicode(raw string) string

ZHToUnicode turn Chinese into unicode

Types

type Buffer added in v0.5.2

type Buffer struct {
	*bytes.Buffer
}

Buffer 内嵌bytes.Buffer,支持连写

func NewBuffer added in v0.5.2

func NewBuffer() *Buffer

func (*Buffer) Append added in v0.5.2

func (b *Buffer) Append(i interface{}) *Buffer

Jump to

Keyboard shortcuts

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