gitlab.com/evatix-go/core@v1.3.55/coretests/GetTrimmedNonEmptySpaceSplit.go (about)

     1  package coretests
     2  
     3  import (
     4  	"sort"
     5  	"strings"
     6  
     7  	"gitlab.com/evatix-go/core/coredata/stringslice"
     8  )
     9  
    10  func GetTrimmedNonEmptySpaceSplit(
    11  	message string,
    12  	isSort bool,
    13  ) []string {
    14  	trimmed := strings.TrimSpace(message)
    15  
    16  	if trimmed == "" {
    17  		return []string{}
    18  	}
    19  
    20  	items := strings.Fields(message)
    21  	items = stringslice.NonWhitespaceTrimSlice(items)
    22  
    23  	if isSort {
    24  		sort.Strings(items)
    25  	}
    26  
    27  	return items
    28  }