filter and map functions I am a JavaScript programmer beginning with Go.  I tried to replicate filter and map functions like JavaScript's, as an exercise.
Here is what I came up with.
The filter function:
func Filter(slice interface{}, cb func(i interface{}) bool) []interface{}{
sliceValues := reflect.ValueOf(slice)
newSlice := []interface{}{}
for i := 0; i &lt; sliceValues.Len(); i++{
    v := sliceValues.Index(i).Interface()
    passed := cb(v)
    if passed{
        newSlice = append(newSlice, v)
    }   
}
return newSlice
}

Usage:
a := []int {1,2,3}

result := Filter(a,func(i interface{}) bool{
    v,_:= i.(int)
    return v &gt; 1
})

fmt.Println(result) // [2 3]

The map function:
func Map(slice interface{}, cb func(i interface{}) interface{}) []interface{}{
sliceValues := reflect.ValueOf(slice)
newSlice := []interface{}{}
for i := 0; i &lt; sliceValues.Len(); i++{
    v := sliceValues.Index(i).Interface()
    modifiedValue := cb(v)
    newSlice = append(newSlice, modifiedValue)
}
return newSlice

}
Usage:
a := []int {1,2,3}

result := Map(a,func(i interface{}) interface{}{
    v,_:= i.(int)
    return v + 1
})

fmt.Println(result) // [2 3 4]
From a mathematics and science genius:

&quot;If I have seen further it is by standing on the shoulders of Giants.&quot; Isaac Newton
Wikipedia: Standing on the shoulders of giants

For Go giants, you might start with Rob Pike.

GitHub - robpike/filter: Simple apply/filter/reduce package.
I wanted to see how hard it was to implement this sort of thing in Go, with as nice an API as I could manage. It wasn't hard.
Having written it a couple of years ago, I haven't had occasion to use it once. Instead, I just use &quot;for&quot; loops.
You shouldn't use it either.

Take Rob Pike's advice and use &quot;for&quot; loops.