gitlab.com/evatix-go/core@v1.3.55/coreutils/stringutil/SafeSubstringStarts.go (about)

     1  package stringutil
     2  
     3  import (
     4  	"gitlab.com/evatix-go/core/constants"
     5  )
     6  
     7  // SafeSubstringStarts
     8  //
     9  // content[startAt:]
    10  // -1 meaning get full text
    11  func SafeSubstringStarts(
    12  	content string,
    13  	startAt int,
    14  ) string {
    15  	length := len(content)
    16  
    17  	if length == 0 || length <= startAt {
    18  		return constants.EmptyString
    19  	}
    20  
    21  	if startAt == -1 {
    22  		return content
    23  	}
    24  
    25  	return content[startAt:]
    26  }