lancet

module
v1.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2024 License: MIT

README


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.
  • 💪 400+ 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 Reverse (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.Reverse(s)
    fmt.Println(rs) //olleh
}

API Documentation

1. Compare package provides a lightweight comparison function on any type.

import "github.com/duke-git/lancet/compare"
Function list:

2. Convertor package contains some functions for data convertion.

import "github.com/duke-git/lancet/convertor"
Function list:

3. Cryptor package is for data encryption and decryption.

import "github.com/duke-git/lancet/cryptor"
Function list:

4. Datetime package supports date and time format and compare.

import "github.com/duke-git/lancet/datetime"
Function list:

5. Fileutil package implements some basic functions for file operations.

import "github.com/duke-git/lancet/fileutil"
Function list:

6. Formatter contains some functions for data formatting.

import "github.com/duke-git/lancet/formatter"
Function list:

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

import "github.com/duke-git/lancet/function"
Function list:

8. Mathutil package implements some functions for math calculation.

import "github.com/duke-git/lancet/mathutil"
Function list:

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

import "github.com/duke-git/lancet/netutil"
Function list:

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

import "github.com/duke-git/lancet/random"
Function list:

11. 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:

12. Slice contains some functions to manipulate slice.

import "github.com/duke-git/lancet/slice"
Function list:

13. Strutil package contains some functions to manipulate string.

import "github.com/duke-git/lancet/strutil"
Function list:

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

import "github.com/duke-git/lancet/system"
Function list:

15. Validator package contains some functions for data validation.

import "github.com/duke-git/lancet/validator"
Function list:

How to Contribute

I really appreciate any code commits which make lancet lib powerful. Please follow the rules below to create your pull request.

  1. Fork the repository.
  2. Create your feature branch.
  3. Commit your changes.
  4. Push to the branch
  5. Create new pull request.

Directories

Path Synopsis
Package compare provides a lightweight comparison function on interface{} type.
Package compare provides a lightweight comparison function on interface{} type.
Package convertor implements some functions to convert data.
Package convertor implements some functions to convert data.
Package cryptor implements some util functions to encrypt and decrypt.
Package cryptor implements some util functions to encrypt and decrypt.
Package fileutil implements some basic functions for file operations
Package fileutil implements some basic functions for file operations
Package formatter implements some functions to format string, struct.
Package formatter implements some functions to format string, struct.
Package function implements some functions for control the function execution and some is for functional programming.
Package function implements some functions for control the function execution and some is for functional programming.
Package internal is for internal use.
Package internal is for internal use.
Package mathutil implements some functions for math calculation.
Package mathutil implements some functions for math calculation.
Package netutil implements some basic functions to send http request and get ip info.
Package netutil implements some basic functions to send http request and get ip info.
Package random implements some basic functions to generate random int and string.
Package random implements some basic functions to generate random int and string.
Package retry is for executing a function repeatedly until it was successful or canceled by the context.
Package retry is for executing a function repeatedly until it was successful or canceled by the context.
Package slice implements some functions to manipulate slice.
Package slice implements some functions to manipulate slice.
Package strutil implements some functions to manipulate string.
Package strutil implements some functions to manipulate string.
Package system contain some functions about os, runtime, shell command.
Package system contain some functions about os, runtime, shell command.
Package validator implements some validate function for string.
Package validator implements some validate function for string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL