Feature
- 👏 Comprehensive, efficient and reusable.
- 💪 250+ go util functions, support string, slice, datetime, net, crypt...
- 💅 Only depend on the go standard library.
- 🌍 Unit test for every exported function.
Installation
Note:
1. For users who use go1.18 and above, it is recommended to install lancet v2.x.x. Cause v2.x.x rewrite all functions with generics of go1.18.
go get github.com/duke-git/lancet/v2 // will install latest version of v2.x.x
2. For users who use version below go1.18, you should install v1.x.x. now latest v1 is v1.2.9.
go get github.com/duke-git/lancet@v1.2.9 // below go1.18, install latest version of v1.x.x
Usage
Lancet organizes the code into package structure, and you need to import the corresponding package name when use it. For example, if you use string-related functions,import the strutil package like below:
import "github.com/duke-git/lancet/v2/strutil"
Example
Here takes the string function ReverseStr (reverse order string) as an example, and the strutil package needs to be imported.
Expand|Select|Wrap|Line Numbers
- package main
- import (
- "fmt"
- "github.com/duke-git/lancet/v2/strutil"
- )
- func main() {
- s := "hello"
- rs := strutil.ReverseStr(s)
- fmt.Println(rs) //olleh
- }