lysstring

package
v0.3.40 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 12 Imported by: 1

README

lysstring

String functions.

Documentation

Overview

Package lysstring contains string functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Camel added in v0.1.48

func Camel(s string) (res string)

Camel removes punctuation, accents, and spaces in s and converts it to camel case My string -> myString

func Convert

func Convert(s, inSep, outSep string, f func(string) string) (res string)

Convert changes value separation of s, e.g. from CSV (,) to TSV (|). If inSep is empty, s is split by character.

func DeAlias added in v0.1.18

func DeAlias[T ~string](in []T) (out []string)

DeAlias converts []T to []string, where T is an alias of string.

func FirstLower added in v0.1.48

func FirstLower(s string) string

FirstLower changes the first character of s to lower case. From https://stackoverflow.com/questions/75988064/make-first-letter-of-string-lower-case-in-golang.

func IsAscii added in v0.1.23

func IsAscii(s string) bool

IsAscii returns true if s only contains ASCII chars. From https://stackoverflow.com/questions/53069040/checking-a-string-contains-only-ascii-characters

func JoinInts added in v0.3.17

func JoinInts[T constraints.Integer](ints []T, sep string) string

JoinInts joins the supplied int slice into a single string separated by sep

func Joined added in v0.1.48

func Joined(s string) (res string)

Joined removes punctuation, accents, and spaces in s and converts it to lower case My string -> mystring

func Kebab added in v0.1.48

func Kebab(name string) (res string)

Kebab removes punctuation and accents in s and changes it to lower case with hyphen separation My string -> my-string

func Pascal added in v0.1.48

func Pascal(s string) (res string)

Pascal removes punctuation, accents, and spaces in s and changes it to Pascal case My string -> MyString

func Rand added in v0.3.33

func Rand(n int) string

Rand creates a random string of length n. From https://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-go, but uses rand/v2 patterns.

func RemoveCharacters added in v0.1.14

func RemoveCharacters(input string, charsToRemove string) string

RemoveCharacters returns input with the chars in charsToRemove removed.

func ReplaceAccents added in v0.1.23

func ReplaceAccents(s string) (res string, err error)

ReplaceAccents replaces accent characters such as "é" with their non-accented equivalents such as "e". Contains special handling for German accents. From https://twin.sh/articles/33/remove-accents-from-characters-in-go.

func SafeFileName added in v0.3.36

func SafeFileName(name, ext string) string

SafeFileName returns a version of name that is safe to use as a file name, with ext appended. It replaces chars that are not letters, digits, hyphens, underscores, or periods with underscores, and trims leading and trailing periods and underscores. If the resulting name is empty, it returns "file" + ext.

func SingleLine added in v0.1.49

func SingleLine(s string) string

SingleLine removes tabs and excess line breaks from s. "a\n\n\tb\n" -> "a\nb". From https://stackoverflow.com/questions/35360080/golang-idiomatic-way-to-remove-a-blank-line-from-a-multi-line-string.

func SingleSpace added in v0.1.49

func SingleSpace(s string) string

SingleSpace removes excess tabs and spaces from s. " a b " -> "a b". From https://stackoverflow.com/questions/37290693/how-to-remove-redundant-spaces-whitespace-from-a-string-in-golang.

func Snake added in v0.1.48

func Snake(s string) (res string)

Snake removes punctuation and accents in s and changes it to lower case with underscore separation My string -> my_string

func StripPunct added in v0.3.33

func StripPunct(s string) string

StripPunct removes Unicode punctuation characters from s.

func Title

func Title(s string) string

Title returns s in title case using non-specific language rules

Types

This section is empty.

Jump to

Keyboard shortcuts

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