strings

package
v2.286.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package strings provides string helpers and small wrappers around the standard library strings package.

This package re-exports a subset of the standard library strings API and adds small convenience helpers. See `Bytes` for converting strings to byte slices without allocation (unsafe).

Index

Constants

View Source
const (
	// Empty is the empty string constant.
	Empty = ""

	// Space is the space string constant.
	Space = " "
)

Variables

This section is empty.

Functions

func Bytes

func Bytes(s string) []byte

Bytes converts s to a []byte without allocating.

The returned slice aliases the memory backing s. It must be treated as read-only, and it must not be retained beyond the lifetime of s.

func Concat

func Concat(ss ...string) string

Concat concatenates ss without a separator.

func Contains

func Contains(s, substr string) bool

Contains is an alias for strings.Contains.

func Count added in v2.194.0

func Count(s, substr string) int

Count is an alias for strings.Count.

func Cut

func Cut(s, sep string) (string, string, bool)

Cut is an alias for strings.Cut.

func CutColon added in v2.12.0

func CutColon(s string) (string, string)

CutColon splits s on the first ":" and returns the parts before and after.

If ":" is not present, the returned after value is empty.

func HasPrefix

func HasPrefix(s, prefix string) bool

HasPrefix is an alias for strings.HasPrefix.

func IsAnyEmpty added in v2.24.0

func IsAnyEmpty(ss ...string) bool

IsAnyEmpty reports whether any of ss are empty.

func IsEmpty

func IsEmpty(s string) bool

IsEmpty reports whether s is empty.

func Join

func Join(sep string, ss ...string) string

Join joins ss with sep.

This helper allows joining variadic strings without allocating a slice at the callsite.

func Repeat

func Repeat(s string, count int) string

Repeat is an alias for strings.Repeat.

func ReplaceAll added in v2.93.0

func ReplaceAll(s, o, n string) string

ReplaceAll is an alias for strings.ReplaceAll.

func ToLower

func ToLower(s string) string

ToLower is an alias for strings.ToLower.

func TrimSpace

func TrimSpace(s string) string

TrimSpace is an alias for strings.TrimSpace.

Types

This section is empty.

Jump to

Keyboard shortcuts

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