lancet alternatives and similar packages
Based on the "Utilities" category.
Alternatively, view lancet alternatives based on common mentions on social networks and blogs.
-
项目文档
基于vite+vue3+gin搭建的开发基础平台(支持TS,JS混用),集成jwt鉴权,权限管理,动态路由,显隐可控组件,分页封装,多点登录拦截,资源权限,上传下载,代码生成器,表单生成器,chatGPT自动查表等开发必备功能。 -
excelize
Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets -
xlsx
(No longer maintained!) Go (golang) library for reading and writing XLSX files. -
godotenv
A Go port of Ruby's dotenv library (Loads environment variables from .env files) -
hystrix-go
Netflix's Hystrix latency and fault tolerance library, for Go -
go-funk
A modern Go utility library which provides helpers (map, find, contains, filter, ...) -
gorequest
GoRequest -- Simplified HTTP client ( inspired by nodejs SuperAgent ) -
goreporter
A Golang tool that does static analysis, unit testing, code review and generate code quality report. -
Kopia
Cross-platform backup tool for Windows, macOS & Linux with fast, incremental backups, client-side end-to-end encryption, compression and data deduplication. CLI and GUI included. -
gojson
Automatically generate Go (golang) struct definitions from example JSON -
create-go-app
✨ Create a new production-ready project with backend, frontend and deploy automation by running one CLI command! -
spinner
Go (golang) package with 90 configurable terminal spinner/progress indicators. -
filetype
Fast, dependency-free Go package to infer binary file types based on the magic numbers header signature -
boilr
:zap: boilerplate template manager that generates files or directories from template repositories -
EaseProbe
A simple, standalone, and lightweight tool that can do health/status checking, written in Go. -
mole
CLI application to create ssh tunnels focused on resiliency and user experience. -
beaver
💨 A real time messaging system to build a scalable in-app notifications, multiplayer games, chat apps in web and mobile apps. -
go-underscore
Helpfully Functional Go - A useful collection of Go utilities. Designed for programmer happiness. -
mimetype
A fast Golang library for media type and file extension detection, based on magic numbers -
JobRunner
Framework for performing work asynchronously, outside of the request flow -
git-time-metric
Simple, seamless, lightweight time tracking for Git
Access the most powerful time series database as a service
Do you think we are missing an alternative of lancet or a related project?
Popular Comparisons
README
Lancet is a comprehensive, efficient, and reusable util function library of go. Inspired by the java apache common package and lodash.js.
English | [简体中文](./README_zh-CN.md)
Feature
- 👏 Comprehensive, efficient and reusable.
- 💪 300+ go util functions, support string, slice, datetime, net, crypt...
- 💅 Only depend on the go standard library.
- 🌍 Unit test for every exported function.
Installation
Note:
- 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
- For users who use version below go1.18, you should install v1.x.x. now latest v1 is v1.3.3.
go get github.com/duke-git/[email protected] // 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 Reverse (reverse order string) as an example, and the strutil package needs to be imported.
package main
import (
"fmt"
"github.com/duke-git/lancet/v2/strutil"
)
func main() {
s := "hello"
rs := strutil.Reverse(s)
fmt.Println(rs) //olleh
}
API Documentation
lancet API doc Thanks @UvDream for contributing.
1. Algorithm package implements some basic algorithm. eg. sort, search.
import "github.com/duke-git/lancet/v2/algorithm"
Function list:
- BubbleSort
- CountSort
- HeapSort
- InsertionSort
- MergeSort
- QuickSort
- SelectionSort
- ShellSort
- BinarySearch
- BinaryIterativeSearch
- LinearSearch
- LRUCache
2. Concurrency package contain some functions to support concurrent programming. eg, goroutine, channel, async.
import "github.com/duke-git/lancet/v2/concurrency"
Function list:
3. Condition package contains some functions for conditional judgment. eg. And, Or, TernaryOperator...
import "github.com/duke-git/lancet/v2/condition"
Function list:
4. Convertor package contains some functions for data convertion.
import "github.com/duke-git/lancet/v2/convertor"
Function list:
- ColorHexToRGB
- ColorRGBToHex
- ToBool
- ToBytes
- ToChar
- ToChannel
- ToFloat
- ToInt
- ToJson
- ToMap
- ToPointer
- ToString
- StructToMap
- MapToSlice
- EncodeByte
- DecodeByte
5. Cryptor package is for data encryption and decryption.
import "github.com/duke-git/lancet/v2/cryptor"
Function list:
- AesEcbEncrypt
- AesEcbDecrypt
- AesCbcEncrypt
- AesCbcDecrypt
- AesCtrCrypt
- AesCfbEncrypt
- AesCfbDecrypt
- AesOfbEncrypt
- AesOfbDecrypt
- Base64StdEncode
- Base64StdDecode
- DesEcbEncrypt
- DesEcbDecrypt
- DesCbcEncrypt
- DesCbcDecrypt
- DesCtrCrypt
- DesCfbEncrypt
- DesCfbDecrypt
- DesOfbEncrypt
- DesOfbDecrypt
- HmacMd5
- HmacSha1
- HmacSha256
- HmacSha512
- Md5String
- Md5File
- Sha1
- Sha256
- Sha512
- GenerateRsaKey
- RsaEncrypt
- RsaDecrypt
6. Datetime package supports date and time format and compare.
import "github.com/duke-git/lancet/v2/datetime"
Function list:
- AddDay
- AddHour
- AddMinute
- BeginOfMinute
- BeginOfHour
- BeginOfDay
- BeginOfWeek
- BeginOfMonth
- BeginOfYear
- EndOfMinute
- EndOfHour
- EndOfDay
- EndOfWeek
- EndOfMonth
- EndOfYear
- GetNowDate
- GetNowTime
- GetNowDateTime
- GetZeroHourTimestamp
- GetNightTimestamp
- FormatTimeToStr
- FormatStrToTime
- NewUnix
- NewUnixNow
- NewFormat
- NewISO8601
- ToUnix
- ToFormat
- ToFormatForTpl
- ToIso8601
7. Datastructure package constains some common data structure. eg. list, linklist, stack, queue, set, tree, graph.
import list "github.com/duke-git/lancet/v2/datastructure/list"
import link "github.com/duke-git/lancet/v2/datastructure/link"
import stack "github.com/duke-git/lancet/v2/datastructure/stack"
import queue "github.com/duke-git/lancet/v2/datastructure/queue"
import set "github.com/duke-git/lancet/v2/datastructure/set"
import tree "github.com/duke-git/lancet/v2/datastructure/tree"
import heap "github.com/duke-git/lancet/v2/datastructure/heap"
import hashmap "github.com/duke-git/lancet/v2/datastructure/hashmap"
Function list:
8. Fileutil package implements some basic functions for file operations.
import "github.com/duke-git/lancet/v2/fileutil"
Function list:
- ClearFile
- CreateFile
- CreateDir
- CopyFile
- FileMode
- MiMeType
- IsExist
- IsLink
- IsDir
- ListFileNames
- RemoveFile
- ReadFileToString
- ReadFileByLine
- Zip
- UnZip
9. Formatter contains some functions for data formatting.
import "github.com/duke-git/lancet/v2/formatter"
Function list:
10. Function package can control the flow of function execution and support part of functional programming
import "github.com/duke-git/lancet/v2/function"
Function list:
11. Maputil package includes some functions to manipulate map.
import "github.com/duke-git/lancet/v2/maputil"
Function list:
12. Mathutil package implements some functions for math calculation.
import "github.com/duke-git/lancet/v2/mathutil"
Function list:
- Average
- Exponent
- Fibonacci
- Factorial
- Max
- MaxBy
- Min
- MinBy
- Percent
- RoundToFloat
- RoundToString
- TruncRound
13. Netutil package contains functions to get net information and send http request.
import "github.com/duke-git/lancet/v2/netutil"
Function list:
- ConvertMapToQueryString
- EncodeUrl
- GetInternalIp
- GetIps
- GetMacAddrs
- GetPublicIpInfo
- GetRequestPublicIp
- IsPublicIP
- IsInternalIP
- HttpRequest
- HttpClient
- SendRequest
- DecodeResponse
14. Random package implements some basic functions to generate random int and string.
import "github.com/duke-git/lancet/v2/random"
Function list:
15. Retry package is for executing a function repeatedly until it was successful or canceled by the context.
import "github.com/duke-git/lancet/v2/retry"
Function list:
16. Slice contains some functions to manipulate slice.
import "github.com/duke-git/lancet/v2/slice"
Function list:
- AppendIfAbsent
- Contain
- ContainSubSlice
- Chunk
- Compact
- Concat
- Count
- Difference
- DifferenceBy
- DifferenceWith
- DeleteAt
- Drop
- Equal
- EqualWith
- Every
- Filter
- Find
- FindLast
- Flatten
- FlattenDeep
- ForEach
- GroupBy
- GroupWith
- IntSlice
- InterfaceSlice
- Intersection
- InsertAt
- IndexOf
- LastIndexOf
- Map
- Reverse
- Reduce
- Replace
- ReplaceAll
- Shuffle
- SortByField
- Some
- StringSlice
- SymmetricDifference
- ToSlice
- ToSlicePointer
- Unique
- UniqueBy
- Union
- UnionBy
- UpdateAt
- Without
- KeyBy
17. Strutil package contains some functions to manipulate string.
import "github.com/duke-git/lancet/v2/strutil"
Function list:
- After
- AfterLast
- Before
- BeforeLast
- CamelCase
- Capitalize
- IsString
- KebabCase
- LowerFirst
- UpperFirst
- PadEnd
- PadStart
- Reverse
- SnakeCase
- SplitEx
- Wrap
- Unwrap
19. System package contain some functions about os, runtime, shell command.
import "github.com/duke-git/lancet/v2/system"
Function list:
19. Validator package contains some functions for data validation.
import "github.com/duke-git/lancet/v2/validator"
Function list:
- ContainChinese
- ContainLetter
- ContainLower
- ContainUpper
- IsAlpha
- IsAllUpper
- IsAllLower
- IsBase64
- IsChineseMobile
- IsChineseIdNum
- IsChinesePhone
- IsCreditCard
- IsDns
- IsEmail
- IsEmptyString
- IsFloatStr
- IsNumberStr
- IsJSON
- IsRegexMatch
- IsIntStr
- IsIp
- IsIpV4
- IsIpV6
- IsStrongPassword
- IsUrl
- IsWeakPassword
- IsZeroValue
20. xerror package implements helpers for errors.
import "github.com/duke-git/lancet/v2/xerror"
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.
- Fork the repository.
- Create your feature branch.
- Commit your changes.
- Push to the branch
- Create new pull request.
*Note that all licence references and agreements mentioned in the lancet README section above
are relevant to that project's source code only.