1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 21:02:27 +08:00
2022-01-12 11:23:51 +08:00
2022-02-07 16:35:01 +08:00
2022-01-21 14:54:55 +08:00
2022-01-21 17:13:31 +08:00
2022-01-19 19:45:18 +08:00
2022-01-09 14:03:46 +08:00
2022-01-24 15:30:22 +08:00
2022-01-22 18:55:41 +08:00
2022-01-22 18:11:52 +08:00
2022-01-28 11:45:50 +08:00
2021-11-29 11:48:12 +08:00
2021-11-28 21:18:19 +08:00
2022-02-08 14:43:57 +08:00
2022-02-08 14:43:57 +08:00


Go version Release GoDoc Go Report Card test codecov License

Lancet is a comprehensive, efficient, and reusable util function library of go. Inspired by the java apache common package and lodash.js.

English | 简体中文

Feature

  • 👏 Comprehensive, efficient and reusable.
  • 💪 170+ common go util functions, support string, slice, datetime, net, crypt...
  • 💅 Only depend on the go standard library.
  • 🌍 Unit test for every exported function.

Installation

go get github.com/duke-git/lancet

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/strutil"

Example

Here takes the string function ReverseStr (reverse order string) as an example, and the strutil package needs to be imported.

package main

import (
    "fmt"
    "github.com/duke-git/lancet/strutil"
)

func main() {
    s := "hello"
    rs := strutil.ReverseStr(s)
    fmt.Println(rs) //olleh
}

API Documentation

Convertor package contains some functions for data convertion.

import "github.com/duke-git/lancet/convertor"

Function list:

Cryptor package is for data encryption and decryption.

import "github.com/duke-git/lancet/cryptor"

Function list:

Datetime package supports date and time format and compare.

import "github.com/duke-git/lancet/datetime"

Function list:

Fileutil package implements some basic functions for file operations.

import "github.com/duke-git/lancet/fileutil"

Function list

Formatter contains some functions for data formatting.

import (
    "github.com/duke-git/lancet/formatter"
)

Function list:

Function package can control the flow of function execution and support part of functional programming

import "github.com/duke-git/lancet/function"

Function list:

Netutil package contains functions to get net information and send http request.

import "github.com/duke-git/lancet/netutil"

Function list:

Random package implements some basic functions to generate random int and string.

import "github.com/duke-git/lancet/random"

Function list:

Retry package is for executing a function repeatedly until it was successful or canceled by the context.

import "github.com/duke-git/lancet/retry"

Function list:

Slice contains some functions to manipulate slice.

import "github.com/duke-git/lancet/slice"

Function list:

Strutil package contains some functions to manipulate string.

import "github.com/duke-git/lancet/strutil"

Function list:

System package contain some functions about os, runtime, shell command.

import "github.com/duke-git/lancet/system"

Function list:

Validator package contains some functions for data validation.

import "github.com/duke-git/lancet/validator"

Function list:

Description
A comprehensive, efficient, and reusable util function library of go.
Readme MIT 11 MiB
Languages
Go 100%