texts

package
v0.0.0-...-e7b361f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package texts provides string truncation.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Truncate

func Truncate(text string, maxLength int, suffix string, exact bool) string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL