strings

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 2 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

This section is empty.

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

func ToCamel

func ToCamel(s string) string

ToCamel converts a string to CamelCase format by removing delimiters and capitalizing appropriate letters.

Example
package main

import (
	"fmt"

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

func main() {
	result := strings.ToCamel("hello_world_example")
	fmt.Println(result)
}
Output:
HelloWorldExample

func ToDelimited

func ToDelimited(s string, delimiter uint8) string

ToDelimited converts a string to delimited.snake.case

Example
package main

import (
	"fmt"

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

func main() {
	result := strings.ToDelimited("HelloWorldExample", '.')
	fmt.Println(result)
}
Output:
hello.world.example

func ToKebab

func ToKebab(s string) string

ToKebab converts a string to kebab-case format using hyphens as delimiters.

Example
package main

import (
	"fmt"

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

func main() {
	result := strings.ToKebab("HelloWorldExample")
	fmt.Println(result)
}
Output:
hello-world-example

func ToLowerCamel

func ToLowerCamel(s string) string

ToLowerCamel converts a string to lowerCamelCase format by removing delimiters and capitalizing appropriate letters.

Example
package main

import (
	"fmt"

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

func main() {
	result := strings.ToLowerCamel("hello_world_example")
	fmt.Println(result)
}
Output:
helloWorldExample

func ToScreamingDelimited

func ToScreamingDelimited(s string, delimiter uint8, ignore string, screaming bool) string

ToScreamingDelimited converts a string to SCREAMING_DELIMITED_CASE

Example
package main

import (
	"fmt"

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

func main() {
	result := strings.ToScreamingDelimited("HelloWorldExample", '.', "", true)
	fmt.Println(result)
}
Output:
HELLO.WORLD.EXAMPLE

func ToScreamingKebab

func ToScreamingKebab(s string) string

ToScreamingKebab converts a string to SCREAMING-KEBAB-CASE format using hyphens as delimiters.

Example
package main

import (
	"fmt"

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

func main() {
	result := strings.ToScreamingKebab("HelloWorldExample")
	fmt.Println(result)
}
Output:
HELLO-WORLD-EXAMPLE

func ToScreamingSnake

func ToScreamingSnake(s string) string

ToScreamingSnake converts a given string to SCREAMING_SNAKE_CASE format using underscores as delimiters.

Example
package main

import (
	"fmt"

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

func main() {
	result := strings.ToScreamingSnake("HelloWorldExample")
	fmt.Println(result)
}
Output:
HELLO_WORLD_EXAMPLE

func ToSnake

func ToSnake(s string) string

ToSnake converts a given string to snake_case format using underscores as delimiters.

Example
package main

import (
	"fmt"

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

func main() {
	result := strings.ToSnake("HelloWorldExample")
	fmt.Println(result)
}
Output:
hello_world_example

func ToSnakeWithIgnore

func ToSnakeWithIgnore(s string, ignore string) string

ToSnakeWithIgnore converts the input string `s` to snake_case format while ignoring characters specified in `ignore`.

Types

This section is empty.

Jump to

Keyboard shortcuts

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