Golang utility library with syntactic sugar.
Gubrak is yet another utility library for Golang, inspired from lodash. Currently we have around 46 reusable functions available, and it'll keep increasing.
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 },
}
*/
}
These are list of available functions that stable.
- gubrak.Chunk()
- gubrak.Compact()
- gubrak.Concat()
- gubrak.Count()
- gubrak.Difference()
- gubrak.Drop()
- gubrak.DropRight()
- gubrak.Each()
- gubrak.EachRight()
- gubrak.Fill()
- gubrak.Filter()
- gubrak.Find()
- gubrak.FindIndex()
- gubrak.FindLast()
- gubrak.FindLastIndex()
- gubrak.First()
- gubrak.ForEach()
- gubrak.ForEachRight()
- gubrak.FromPairs()
- gubrak.GroupBy()
- gubrak.Head()
- gubrak.Includes()
- gubrak.IndexOf()
- gubrak.Initial()
- gubrak.Intersection()
- gubrak.IsArray()
- gubrak.IsBool()
- gubrak.IsChannel()
- gubrak.IsDate()
- gubrak.IsEmpty()
- gubrak.IsEmptyString()
- gubrak.IsFloat()
- gubrak.IsFunction()
- gubrak.IsInt()
- gubrak.IsMap()
- gubrak.IsNil()
- gubrak.IsNumeric()
- gubrak.IsPointer()
- gubrak.IsSlice()
- gubrak.IsString()
- gubrak.IsStructObject()
- gubrak.IsTrue()
- gubrak.IsUint()
- gubrak.IsZeroNumber()
- gubrak.Join()
- gubrak.KeyBy()
- gubrak.Last()
- gubrak.LastIndexOf()
- gubrak.Map()
- gubrak.Now()
- gubrak.Nth()
- gubrak.OrderBy()
- gubrak.Partition()
- gubrak.Pull()
- gubrak.PullAll()
- gubrak.PullAt()
- gubrak.RandomInt()
- gubrak.RandomString()
- gubrak.RandomStringAlphabet()
- gubrak.Reduce()
- gubrak.Reject()
- gubrak.Remove()
- gubrak.Reverse()
- gubrak.Sample()
- gubrak.SampleSize()
- gubrak.Shuffle()
- gubrak.Size()
- gubrak.SortBy()
- gubrak.Tail()
- gubrak.Take()
- gubrak.TakeRight()
- gubrak.Union()
- gubrak.Uniq()
- gubrak.Without()
- gubrak.Xor()
Fork ➜ Create branch ➜ Commit ➜ Push ➜ Pull Requests
MIT License