Skip to content

changchanghwang/godash

Repository files navigation

godash

Lodash style go library

Installation

go get github.com/changchanghwang/godash

Usage

You can use with importing `godash``

import "github.com/changchanghwang/godash"

Quick LInks

For now, there is only supported Slice, Array mehotds

Slice, Array

Map
import "github.com/changchanghwang/godash"

// without chain
godash.Map([]int{1,2,3,4,5}, func(v int) int {
    return v * 2
}) // []int{2,4,6,8,10}

// with chain
godash.Chain([]int{1,2,3,4,5}).Map(func(v int) int {
    return v * 2
}).Value() // []int{2,4,6,8,10}
Head
import "github.com/changchanghwang/godash"

// without chain
godash.Head([]int{1,2,3,4,5}) // 1, true
godash.Head([]int{}) // 0, false

// with chain
godash.Chain([]int{1,2,3,4,5}).Head() // 1, true
godash.Chain([]int{}).Head() // 0, false
Tail
import "github.com/changchanghwang/godash"

// with chain
godash.Tail([]int{1,2,3,4,5}) // []int{2,3,4,5}
godash.Tail([]int{}) // []int{}

// with chain
godash.Chain([]int{1,2,3,4,5}).Tail() // []int{2,3,4,5}
godash.Chain([]int{}).Tail() // []int{}
DeepCopySlice
import "github.com/changchanghwang/godash"

arr := []int{1,2,3,4,5}
godash.DeepCopySlice(arr) // []int{1,2,3,4,5}
Filter
import "github.com/changchanghwang/godash"

// without chain
arr := []int{1,2,3,4,5}
godash.Filter(arr, func(v int) bool {
  return v > 3
}) // []int{4,5}

// with chain
arr := []int{1,2,3,4,5}
godash.Chain(arr).Filter(func(v int) bool {
  return v > 3
}).Value() // []int{4,5}

About

Lodash style go library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages