Underscore.go是一个非常有帮助的Go实用程序集。类似underscore.js,但是是GO的工具库。
计划功能:
godoc
contains
indexOf
workerpools
paralleleach
parallelmapwithworkerpool
refactortomakefunctionsfirstparameter(egEachfunc(func(A),[]A))
handlemaps&slices
all
any
none
示例:
import "un"s := []string{"a", "b", "c", "d"}fn := func(s string) string { return s + "!"}// Generic, interface based helpersm:= un.Map(s, fn)fmt.Println(m) //["a!", "b!", "c!", "d!"]// Define your own typed functionsvar SMap func([]string, func(string) string) []stringun.MakeMap(&SMap)m := un.SMap(s, fn)fmt.Println(m) //["a!", "b!", "c!", "d!"]
评论