str

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package str contains string functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanSplit

func CleanSplit(text, sep string) []string

CleanSplit splits the text by separator, and trims each part's extra whitespace

func CleanSplitN

func CleanSplitN(text, sep string, n int) []string

CleanSplitN splits the text by separator, maximum of N parts, then trims each part's extra whitespace

func CleanSplitter

func CleanSplitter(sep string) func(string) []string

CleanSplitter creates a function that splits the text by separator, and trims each part's extra whitespace

func CleanSplitterN

func CleanSplitterN(sep string, n int) func(string) []string

CleanSplitterN creates a function that splits the text by separator, maximum of N parts, and trims each part's whitespace

func Guard

func Guard(text, guard string) string

Guard returns the guard string if given string is empty, otherwise returns the given string

func IsEmpty

func IsEmpty(text string) bool

IsEmpty checks if string is empty

func Join

func Join(glue string, parts ...string) string

Join joins the strings parts by given glue

func Len

func Len(text string) int

Len returns the string length

func NotEmpty

func NotEmpty(text string) bool

NotEmpty checks if string is not empty

func Repeat

func Repeat(count int, text, glue string) string

Repeat creates a new string by repeating given string and joining by glue

func SpaceSplit

func SpaceSplit(text string) []string

SpaceSplit splits the text by whitespace

func Wrap

func Wrap(text, wrapper string) string

Wrap wraps the given text with the given wrapper string (first char = left, second char= right)

func WrapList

func WrapList(items []string, wrapper string) string

WrapList joins the list items with a comma, and wraps the resulting string in given text (first char = left, second char = right)

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder is a utility type for building strings

func NewBuilder

func NewBuilder() *Builder

NewBuilder creates a new string Builder

func (*Builder) Add

func (b *Builder) Add(item string)

Add adds a string to the string Builder

func (*Builder) AddFmt

func (b *Builder) AddFmt(template string, args ...any)

AddFmt adds a formatted string to the string Builder

func (*Builder) AddItems

func (b *Builder) AddItems(items ...string)

AddItems adds multiple strings to the string Builder

func (*Builder) Build

func (b *Builder) Build(glue string) string

Build builds the string parts, joined by the glue

Jump to

Keyboard shortcuts

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