gitlab.com/evatix-go/core@v1.3.55/internal/strutilinternal/NonEmptySlicePtr.go (about)

     1  package strutilinternal
     2  
     3  func NonEmptySlicePtr(slice *[]string) *[]string {
     4  	if slice == nil {
     5  		return &[]string{}
     6  	}
     7  
     8  	length := len(*slice)
     9  
    10  	if length == 0 {
    11  		return &[]string{}
    12  	}
    13  
    14  	newSlice := make(
    15  		[]string,
    16  		0,
    17  		length)
    18  
    19  	for _, s := range *slice {
    20  		if s != "" {
    21  			newSlice = append(newSlice, s)
    22  		}
    23  	}
    24  
    25  	return &newSlice
    26  }