mamaz / gubrak

⚙️ Golang utility library with syntactic sugar. It's like lodash, but for golang.

Home Page:https://godoc.org/github.com/novalagung/gubrak

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GUBRAK

Golang utility library with syntactic sugar. It's like lodash, but for golang.

Go Report Card Build Status Coverage Status

Gubrak is yet another utility library for Golang, inspired from lodash. Currently we have around 73 reusable functions available, we'll definitely adding more!

Installation

go get -u github.com/novalagung/gubrak

Documentation

Hello World Example

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 },
    }
    */
}

APIs

Below are the list of available functions on gubrak:

ChunkCompactConcatCountDifferenceDropDropRightEachEachRightFillFilterFindFindIndexFindLastFindLastIndexFirstForEachForEachRightFromPairsGroupByHeadIncludesIndexOfInitialIntersectionIsArrayIsBoolIsChannelIsDateIsEmptyIsEmptyStringIsFloatIsFunctionIsIntIsMapIsNilIsNumericIsPointerIsSliceIsStringIsStructObjectIsTrueIsUintIsZeroNumberJoinKeyByLastLastIndexOfMapNowNthOrderByPartitionPullPullAllPullAtRandomIntRandomStringReduceRejectRemoveReverseSampleSampleSizeShuffleSizeSortByTailTakeTakeRightUnionUniqWithout

Test

go get -u github.com/novalagung/gubrak
dep ensure
go test -cover -race -v ./... 

Contribution

Fork ➜ Create branch ➜ Commit ➜ Push ➜ Pull Requests

License

MIT License

About

⚙️ Golang utility library with syntactic sugar. It's like lodash, but for golang.

https://godoc.org/github.com/novalagung/gubrak

License:MIT License


Languages

Language:Go 100.0%