Skip to content

Instantly share code, notes, and snippets.

@mottet-dev
Created June 20, 2019 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mottet-dev/683eb6822f0a7bd3aee0fa665cb43a60 to your computer and use it in GitHub Desktop.
Save mottet-dev/683eb6822f0a7bd3aee0fa665cb43a60 to your computer and use it in GitHub Desktop.
Go Funk - Reduce
package main
import (
"fmt"
"github.com/thoas/go-funk"
)
func main() {
baseSlice := []int{1, 2, 3, 4, 5}
sum := funk.Reduce(baseSlice, func(acc, elem int) int { return acc + elem }, 0)
fmt.Println(baseSlice)
fmt.Println(sum)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment