Underscore.goGO 工具库
Underscore.go 是一个非常有帮助的 Go 实用程序集。类似 underscore.js,但是是 GO 的工具库。
计划功能:
-
godoc
-
contains
-
indexOf
-
worker pools
-
parallel each
-
parallel map with worker pool
-
refactor to make functions first parameter (eg Each func(func(A), []A))
-
handle maps & slices
-
all
-
any
-
none
示例:
import "un"s := []string{"a", "b", "c", "d"} fn := func(s string) string { return s + "!" } // Generic, interface based helpers m:= un.Map(s, fn) fmt.Println(m) //["a!", "b!", "c!", "d!"] // Define your own typed functions var SMap func([]string, func(string) string) []string un.MakeMap(&SMap) m := un.SMap(s, fn) fmt.Println(m) //["a!", "b!", "c!", "d!"]
评论