Golang utility library with syntactic sugar. It's like lodash, but for golang.
Gubrak is yet another utility library for Golang, inspired from lodash. Currently we have around 73 reusable functions available, we'll definitely adding more!
go get -u github.com/novalagung/gubrak
package main
import (
"github.com/novalagung/gubrak"
"fmt"
)
type Sample struct {
EbookName string
DailyDownloads int
}
func main() {
data := []Sample{
{ EbookName: "clean code", DailyDownloads: 10000 },
{ EbookName: "rework", DailyDownloads: 12000 },
{ EbookName: "detective comics", DailyDownloads: 11500 },
}
result, err := gubrak.Filter(data, func(each Sample) bool {
return each.DailyDownloads > 11000
})
if err != nil {
fmt.Println("Error!", err.Error)
return
}
fmt.Printf("%#v \n", result.([]Sample))
/*
[]Sample{
{ EbookName: "rework", DailyDownloads: 12000 },
{ EbookName: "detective comics", DailyDownloads: 11500 },
}
*/
}
Below are the list of available functions on gubrak:
Chunk • Compact • Concat • Count • Difference • Drop • DropRight • Each • EachRight • Fill • Filter • Find • FindIndex • FindLast • FindLastIndex • First • ForEach • ForEachRight • FromPairs • GroupBy • Head • Includes • IndexOf • Initial • Intersection • IsArray • IsBool • IsChannel • IsDate • IsEmpty • IsEmptyString • IsFloat • IsFunction • IsInt • IsMap • IsNil • IsNumeric • IsPointer • IsSlice • IsString • IsStructObject • IsTrue • IsUint • IsZeroNumber • Join • KeyBy • Last • LastIndexOf • Map • Now • Nth • OrderBy • Partition • Pull • PullAll • PullAt • RandomInt • RandomString • Reduce • Reject • Remove • Reverse • Sample • SampleSize • Shuffle • Size • SortBy • Tail • Take • TakeRight • Union • Uniq • Without
go get -u github.com/novalagung/gubrak
dep ensure
go test -cover -race -v ./...
Fork ➜ Create branch ➜ Commit ➜ Push ➜ Pull Requests
MIT License