百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

genesis

> 编程语言
开源

所有您需要的 Go 通用函数!

351 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

所有您需要的 Go 通用函数!

Genesis

Generic functions for Go. Bringing the beauty of functional programming in Go 1.18+.

** Features:**

  • ️ Over 170 generic functions for channels, maps, and slices.
  • Uses the power of Go 1.18+ generics.
  • No code generation.
  • No dependencies (except is for testing).
  • Pure Go.
  • Sync and async versions of all the main functions.

** When to use:**

  • In a big project. More the project grows, more you find yourself writing boring generic code like "Min". Break the cycle.
  • In a team project. Each line of code you write means higher maintenance cost that in turn means loosing time and money.
  • In a pet project. Leave the boring stuff to us, focus on the fun parts.
  • When readability matters. slices.Shrink is a function with a human-friendly name and documentation. s[:len(s):len(s)] is a jibberish and black magic. Prefer the former.
  • When you miss some conveniences that come in other languages out-of-the-box.
  • When you write a highly concurrent code and don't want to manually implement code for cancellation, results collection and ordering, worker groups, context, etc.

** What's inside**:

  • Filter, Map, and Reduce for data processing on steroids.
  • FilterAsync, MapAsync, and ReduceAsync for making your code fast and concurrent with a single line of code.
  • Grow and Shrink for reducing memory allocations.
  • Permutations and Product for simple iterations.
  • Shuffle and Sort for randomization.
  • Any and All for simple flow control.
  • Range, Count, and Cycle for generating sequences.

And much more.

Installation

bash
go get github.com/life4/genesis

Examples

Find the minimal value in a slice of ints:

go
lambdas.Must(slices.Min([]int{42, 7, 13})) == 7

Double values in a slice of ints:

go
slices.Map([]int{4, 8, 15}, func(el int) int { return el * 2 })

Concurrently check status codes for multiple URLs:

go
urls := []string{
    "https://go.dev/",
    "https://golang.org/",
    "https://google.com/",
}
codes := slices.MapAsync(
    urls, 0,
    func(url string) int {
        return lambdas.Must(http.Get(url)).StatusCode
    },
)

Usage

Genesis contains the following packages:

  • slices: generic functions for slices ([]T).
  • maps: generic functions for maps (map[K]V).
  • channels: generic function for channels (chan T).
  • ⚙️ sets: generic function for sets (map[T]struct{}).
  • lambdas: helper generic functions to work with slices.Map and similar.

See DOCUMENTATION for more info.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Goelixirenumerlangfp

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言