gitlab.com/evatix-go/core@v1.3.55/coreutils/stringutil/SplitLeftRightTrimmed.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 SplitLeftRightTrimmed(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 strings.TrimSpace(first), strings.TrimSpace(splits[coreindexes.Second])
    20  	}
    21  
    22  	return strings.TrimSpace(first), constants.EmptyString
    23  }