Skip to content

Latest commit

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date

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")
ifnumErr!=nil {
panic(numErr)
}
age,ageErr:=strconv.Itoa("18")
ifageErr!=nil {
panic(ageErr)
}

Must get

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

1.2. Wrap Error

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

output

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

2. String processing

2.1. StartWith

ifstr.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

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages