truncate

package
v1.24.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TruncateString

func TruncateString(s string, opt TruncateStringOptions) string

TruncateString will attempt to truncate a string to a max, adding a prefix to avoid collisions. Will never return a string longer than maxLength chars

Types

type TruncateStringOptions

type TruncateStringOptions struct {
	// AlwaysAddHash will always cause the hash to be appended.
	// Useful to stop users assuming that the name will never be truncated.
	AlwaysAddHash bool

	// MaxLength controls the maximum length of the string.
	MaxLength int

	// HashLength controls the length of the hash to be appended.
	HashLength int
}

TruncateStringOptions contains parameters for how we truncate strings

Jump to

Keyboard shortcuts

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