Skip to content

lingdor/spannerlib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spannerlib

a common base lib for golang

Get start

go get github.com/lingdor/spannerlib

Features

1. Exception processing

1.1 Must get value and panic when wrong

Normal

num,numErr:=strconv.Itoa("123")
if numErr!=nil {
    panic(numErr)
}
age,ageErr:=strconv.Itoa("18")
if ageErr!=nil {
    panic(ageErr)
}

Must get

num := E.Must1(strconv.Itoa("123"))
//or
age := E.Catch1(strconv.Itoa("123")).IfErrorDataFunc(func()any{
    return "number was input wrong"
}).Must()
//or
num:=E.Catch1(strconv.Itoa("123")).Do(func(err error){
    panic(err)
})

1.2. Wrap Error

err:=fmt.Errorf("123")
err:=errors.Wrap(err,0,"msg")

fmt.printf("%v",err)

output

Exception MSG
testing.tRunner(/usr/local/go/src/testing/testing.go:1689)

2. String processing

2.1. StartWith

if str.StartWith("hello world","hello") {
//true
}

2.2. StringPick

fmt.Println(E.Must1(StringPick("<html><body>123</body></html>", "<body>", "</body>")))

output:


123

About

a common base lib for golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages