Documentation
¶
Overview ¶
Package texts provides string truncation.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Truncate ¶
Truncate shortens text until the length of the shortened text and appended suffix is equal to or less than maxLength. If exact is true, text is cut mid-word.
Example ¶
package main
import (
"fmt"
"github.com/ChristianSiegert/go-packages/texts"
)
func main() {
fmt.Println(texts.Truncate("Hello world", 10, "…", false))
fmt.Println(texts.Truncate("Hello world", 10, "…", true))
}
Output: Hello … Hello wor…
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.