gitlab.com/evatix-go/core@v1.3.55/coredata/stringslice/LinesSimpleProcessNoEmpty.go (about) 1 package stringslice 2 3 import ( 4 "gitlab.com/evatix-go/core/constants" 5 ) 6 7 // LinesSimpleProcessNoEmpty split text using constants.NewLineUnix 8 // then returns lines processed by lineProcessor and don't take any empty string in the output. 9 // Empty string lineOut will be discarded from the final outputs. 10 func LinesSimpleProcessNoEmpty( 11 splitsLines []string, 12 lineProcessor func(lineIn string) (lineOut string), 13 ) []string { 14 if len(splitsLines) == 0 { 15 return []string{} 16 } 17 18 slice := Make(constants.Zero, len(splitsLines)) 19 20 for _, lineIn := range splitsLines { 21 lineOut := lineProcessor(lineIn) 22 23 if lineOut == constants.EmptyString { 24 continue 25 } 26 27 slice = append(slice, lineOut) 28 } 29 30 return slice 31 }