Skip to content
Node: arr.some(fn)github.com/sahilkhaire/gox/slice

Some

Overview

Some reports whether fn is true for any element (Array.some).

If you are coming from Node.js, the closest pattern is arr.some(fn).

Signature

go
func Some[T any](in []T, fn func(T) bool) bool

Compare: Node.js · Standard Go · gox

js
arr.some(fn)
go
// Manual loop or Go 1.21+ slices package
for _, v := range items {
    // transform or filter v
}
go
import "github.com/sahilkhaire/gox/slice"

slice.Some(arr, fn)

Example

go
import "github.com/sahilkhaire/gox/slice"

slice.Some(arr, fn)

Tips

Chain Filter, Map, and Reduce for lodash-style pipelines. Results are new slices — inputs are never mutated.

Standard library alternative

Use a for loop or Go 1.21+ slices package helpers from the standard library.

Back to slice package overview

MIT Licensed · Built for Node.js developers moving to Go