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

     1  package stringslice
     2  
     3  func FirstLastDefaultStatus(slice []string) *FirstLastStatus {
     4  	length := len(slice)
     5  
     6  	if length == 0 {
     7  		return InvalidFirstLastStatus()
     8  	}
     9  
    10  	if length == 1 {
    11  		return InvalidFirstLastStatusForLast(slice[0])
    12  	}
    13  
    14  	// length >= 2
    15  	return &FirstLastStatus{
    16  		First:    slice[0],
    17  		Last:     slice[length-1],
    18  		IsValid:  true,
    19  		HasFirst: true,
    20  		HasLast:  true,
    21  	}
    22  }