strings

package
v4.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 9 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, error)

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

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 uint32
}

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