gitlab.com/evatix-go/core@v1.3.55/coredata/stringslice/PrependNew.go (about)

     1  package stringslice
     2  
     3  import "gitlab.com/evatix-go/core/constants"
     4  
     5  func PrependNew(
     6  	secondSlice []string,
     7  	prependingItems ...string,
     8  ) *[]string {
     9  	sliceLength := len(secondSlice)
    10  	additionalItemsLength := len(prependingItems)
    11  
    12  	newSlice := make(
    13  		[]string,
    14  		constants.Zero,
    15  		sliceLength+additionalItemsLength)
    16  
    17  	if additionalItemsLength > 0 {
    18  		newSlice = append(newSlice, prependingItems...)
    19  	}
    20  
    21  	if sliceLength > 0 {
    22  		newSlice = append(newSlice, secondSlice...)
    23  	}
    24  
    25  	return &newSlice
    26  }