gitlab.com/evatix-go/core@v1.3.55/coredata/stringslice/ExpandBySplitsPtr.go (about) 1 package stringslice 2 3 import ( 4 "strings" 5 6 "gitlab.com/evatix-go/core/constants" 7 ) 8 9 // ExpandBySplitsPtr 10 // Take each slice item, split and add to the new slice array and returns it. 11 func ExpandBySplitsPtr( 12 slice *[]string, 13 splitters ...string, 14 ) *[]string { 15 length := LengthOfPointer(slice) 16 if length == 0 { 17 return &[]string{} 18 } 19 20 splitExpandFunc := func(line string) *[]string { 21 if len(splitters) == 0 { 22 return &[]string{} 23 } 24 25 newExpandedSlice := make([]string, 0, constants.Capacity8) 26 27 for _, splitter := range splitters { 28 lines := strings.Split(line, splitter) 29 newExpandedSlice = append(newExpandedSlice, lines...) 30 } 31 32 return &newExpandedSlice 33 } 34 35 expandedSlicesOfSlice := ExpandByFunc(slice, splitExpandFunc) 36 37 return expandedSlicesOfSlice 38 }