strings

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

Package strings provides utility functions for string manipulation and processing.

This package offers a collection of helper functions for common string operations including transformations, validations, and conversions that complement the standard library's strings package.

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// ToSnake converts a string to snake_case format.
	ToSnake = strcase.ToSnake
	// ToSnakeWithIgnore converts a string to snake_case format, ignoring specific characters.
	ToSnakeWithIgnore = strcase.ToSnakeWithIgnore
	// ToScreamingSnake converts a string to SCREAMING_SNAKE_CASE format.
	ToScreamingSnake = strcase.ToScreamingSnake
	// ToKebab converts a string to kebab-case format.
	ToKebab = strcase.ToKebab
	// ToScreamingKebab converts a string to SCREAMING-KEBAB-CASE format.
	ToScreamingKebab = strcase.ToScreamingKebab
	// ToDelimited converts a string to a custom delimiter-separated format.
	ToDelimited = strcase.ToDelimited
	// ToScreamingDelimited converts a string to SCREAMING custom delimiter-separated format.
	ToScreamingDelimited = strcase.ToScreamingDelimited
	// ToCamel converts a string to CamelCase format.
	ToCamel = strcase.ToCamel
	// ToLowerCamel converts a string to lowerCamelCase format.
	ToLowerCamel = strcase.ToLowerCamel
)

Functions

func PadLeft added in v0.2.0

func PadLeft(s string, n int) string

PadLeft prepends spaces to the left of the input string s until it reaches the specified rune length n.

Example
package main

import (
	"fmt"

	"github.com/foomo/go/strings"
)

func main() {
	result := strings.PadLeft("hello", 10)
	fmt.Printf("'%s'", result)
}
Output:
'     hello'

func PadRight added in v0.2.0

func PadRight(s string, n int) string

PadRight appends spaces to the right of the input string s until it reaches the specified rune length n.

Example
package main

import (
	"fmt"

	"github.com/foomo/go/strings"
)

func main() {
	result := strings.PadRight("hello", 10)
	fmt.Printf("'%s'", result)
}
Output:
'hello     '

func RemoveAll added in v0.2.0

func RemoveAll(s string, substrings ...string) string

RemoveAll removes all occurrences of each substring from s in a single pass.

Example
package main

import (
	"fmt"

	"github.com/foomo/go/strings"
)

func main() {
	result := strings.RemoveAll("hello world", "o", "l")
	fmt.Println(result)
}
Output:
he wrd

Types

This section is empty.

Jump to

Keyboard shortcuts

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