src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

truncate.go (195B)


      1 package text
      2 
      3 import "strings"
      4 
      5 func Truncate(text string, width int) string {
      6 	if width <= 0 {
      7 		return ""
      8 	}
      9 	if len(text) < width {
     10 		return text
     11 	}
     12 
     13 	return strings.TrimSpace(text[:width])
     14 }