github.com/go-board/x-go@v0.1.2-0.20220610024734-db1323f6cb15/xslice/for_each.go (about)

     1  package xslice
     2  
     3  func ForEach(a []interface{}, fn func(x interface{})) {
     4  	for _, x := range a {
     5  		fn(x)
     6  	}
     7  }
     8  
     9  func ForEachString(a []string, fn func(x string)) {
    10  	for _, x := range a {
    11  		fn(x)
    12  	}
    13  }
    14  
    15  func ForEachInt(a []int, fn func(x int)) {
    16  	for _, x := range a {
    17  		fn(x)
    18  	}
    19  }
    20  
    21  func ForEachInt64(a []int64, fn func(x int64)) {
    22  	for _, x := range a {
    23  		fn(x)
    24  	}
    25  }