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

     1  package stringslice
     2  
     3  import "gitlab.com/evatix-go/core/constants"
     4  
     5  func FirstLastDefault(slice []string) (first, last string) {
     6  	length := len(slice)
     7  
     8  	if length == 0 {
     9  		return constants.EmptyString, constants.EmptyString
    10  	}
    11  
    12  	if length == 1 {
    13  		return slice[0], constants.EmptyString
    14  	}
    15  
    16  	// length >= 2
    17  	return slice[0], slice[length-1]
    18  }