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

     1  package stringutil
     2  
     3  import (
     4  	"strings"
     5  
     6  	"gitlab.com/evatix-go/core/constants"
     7  	"gitlab.com/evatix-go/core/coreindexes"
     8  )
     9  
    10  func SplitLeftRight(s, separator string) (left, right string) {
    11  	splits := strings.SplitN(
    12  		s, separator,
    13  		ExpectedLeftRightLength)
    14  
    15  	length := len(splits)
    16  	first := splits[coreindexes.First]
    17  
    18  	if length == ExpectedLeftRightLength {
    19  		return first, splits[coreindexes.Second]
    20  	}
    21  
    22  	return first, constants.EmptyString
    23  }