gitlab.com/evatix-go/core@v1.3.55/coredata/stringslice/ExpandByFunc.go (about) 1 package stringslice 2 3 // ExpandByFunc Don't include nil or empty slice from expand 4 func ExpandByFunc( 5 slice *[]string, 6 expandFunc func(line string) *[]string, 7 ) *[]string { 8 length := LengthOfPointer(slice) 9 if length == 0 { 10 return &[]string{} 11 } 12 13 sliceOfSlices := make( 14 []*[]string, 15 0, 16 length) 17 18 for _, line := range *slice { 19 expandedLines := expandFunc(line) 20 if expandedLines == nil || len(*expandedLines) == 0 { 21 continue 22 } 23 24 sliceOfSlices = append(sliceOfSlices, expandedLines) 25 } 26 27 return MergeNewSlicesPtrOfSlicesPtr(&sliceOfSlices) 28 }