470,590 Members | 2,620 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Share your developer knowledge by writing an article on Bytes.

lancet (util function library of go) released v2.0.0, fully supports go generic features

lancet is a comprehensive, efficient, and reusable util function library of go. This release v2.0.0, which upgrade to go1.18, applies generics to rewrite most of the functions. At the same time, 70+ functions have been added.


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


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


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"


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
  1. package main
  3. import (
  4.     "fmt"
  5.     "github.com/duke-git/lancet/v2/strutil"
  6. )
  8. func main() {
  9.     s := "hello"
  10.     rs := strutil.ReverseStr(s)
  11.     fmt.Println(rs) //olleh
  12. }
Link to API Documentation
4 Weeks Ago #1
0 6830

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Chris Jackson | last post: by
6 posts views Thread by Paul M. | last post: by
2 posts views Thread by mirandacascade | last post: by
1 post views Thread by rich_sposato | last post: by
reply views Thread by info | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.