strings

package
v4.0.0-pre-2 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package strings contains functions to manipulate strings

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CamelCase

func CamelCase(in string) string

CamelCase -

func Indent

func Indent(width int, indent, s string) string

Indent - indent each line of the string with the given indent string. Any indent characters are permitted, except for '\n'.

TODO: return an error if the indent string contains '\n' instead of succeeding

func KebabCase

func KebabCase(in string) string

KebabCase -

func ShellQuote

func ShellQuote(s string) string

ShellQuote - generate a POSIX shell literal evaluating to a string

func SkipLines

func SkipLines(skip int, in string) (string, error)

SkipLines - skip the given number of lines (ending with \n) from the string. If skip is greater than the number of lines in the string, an empty string is returned.

func SnakeCase

func SnakeCase(in string) string

SnakeCase -

func Sort deprecated

func Sort(list []string) []string

Sort - return an alphanumerically-sorted list of strings

Deprecated: use coll.Sort instead

func Trunc

func Trunc(length int, s string) string

Trunc - truncate a string to the given length

func WordWrap

func WordWrap(in string, opts WordWrapOpts) string

WordWrap - insert line-breaks into the string, before it reaches the given width.

Types

type WordWrapOpts

type WordWrapOpts struct {
	// Line-break sequence to insert (defaults to "\n")
	LBSeq string

	// The desired maximum line length in characters (defaults to 80)
	Width uint
}

WordWrapOpts defines the options to apply to the WordWrap function

Jump to

Keyboard shortcuts

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