Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsJul 18, 2026·3 min de lecture

Lancet — Comprehensive Utility Function Library for Go

A reusable Go utility library providing 600+ functions covering strings, slices, maps, concurrency, cryptography, file I/O, networking, and more, all using Go generics.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Lancet Overview
Commande d'installation directe
npx -y tokrepo@latest install 0916b73c-8243-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

Introduction

Lancet is a Go utility library inspired by JavaScript's Lodash and Java's Apache Commons. It provides a broad collection of helper functions organized into packages, covering common operations that Go developers would otherwise write repeatedly. It leverages Go generics for type-safe collection operations.

What Lancet Does

  • Provides 600+ utility functions across 30+ packages for common Go tasks
  • Covers string manipulation, slice/map operations, math, file I/O, and HTTP helpers
  • Uses Go generics for type-safe collection functions like Filter, Map, Reduce, and GroupBy
  • Includes concurrency utilities, retry logic, and rate limiting helpers
  • Offers cryptography wrappers, random generation, and validation functions

Architecture Overview

Lancet is organized as a collection of focused packages within a single module. Each package (strutil, slice, maputil, fileutil, netutil, cryptoutil, etc.) is independent and can be imported individually. Functions are designed as pure, stateless utilities with no global state. Generics-based packages require Go 1.18+. The library has zero external dependencies — every function is implemented in pure Go.

Self-Hosting & Configuration

  • Install with go get github.com/duke-git/lancet/v2 — requires Go 1.18+
  • Import only the packages you need: lancet/v2/slice, lancet/v2/strutil, etc.
  • No configuration required — all functions are stateless utilities
  • Each package can be used independently without pulling in the entire library
  • Full documentation available at pkg.go.dev with examples for every function

Key Features

  • Zero dependencies — pure Go implementation with no external packages
  • Generics support — type-safe collection operations without interface{} casting
  • Comprehensive coverage — strings, slices, maps, math, datetime, file, net, crypto, system
  • Well-tested — each function includes unit tests and benchmark tests
  • Consistent API design — predictable naming and parameter conventions across packages

Comparison with Similar Tools

  • Lodash (JS) — Lancet serves the same role for Go that Lodash serves for JavaScript
  • samber/lo — another Go generics utility library; Lancet covers more domains beyond collections
  • thoas/go-funk — pre-generics utility library using reflection; Lancet uses generics for type safety
  • standard library — Go stdlib covers basics; Lancet fills gaps like CamelCase, Chunk, and Retry

FAQ

Q: Does Lancet require Go generics? A: The v2 branch requires Go 1.18+. A v1 branch exists for older Go versions but without generics-based functions.

Q: Will importing Lancet bloat my binary? A: No, Go only compiles the packages and functions you actually import and call.

Q: How stable is the API? A: Lancet follows semantic versioning. The v2 API is considered stable with backward-compatible additions.

Q: Can I contribute new utility functions? A: Yes, the project accepts contributions. New functions should include documentation, tests, and benchmarks.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires