github.com/condensat/bank-core@v0.1.0/database/utils/strings.go (about)

     1  // Copyright 2020 Condensat Tech. All rights reserved.
     2  // Use of this source code is governed by a MIT
     3  // license that can be found in the LICENSE file.
     4  
     5  package utils
     6  
     7  import (
     8  	"fmt"
     9  	"strings"
    10  )
    11  
    12  const (
    13  	Ellipsis = "..."
    14  )
    15  
    16  func EllipsisCentral(str string, limit int) string {
    17  	if len(str) <= 2*limit {
    18  		return str
    19  	}
    20  	return fmt.Sprintf("%s%s%s", str[:limit], Ellipsis, str[len(str)-limit:])
    21  }
    22  
    23  func ContainEllipsis(str string) bool {
    24  	return strings.Contains(str, Ellipsis)
    25  }
    26  
    27  func SplitEllipsis(str string) []string {
    28  	return strings.Split(str, Ellipsis)
    29  }