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
- func Bytes(s string) []byte
- func Concat(ss ...string) string
- func Contains(s, substr string) bool
- func Count(s, substr string) int
- func Cut(s, sep string) (string, string, bool)
- func CutColon(s string) (string, string)
- func HasPrefix(s, prefix string) bool
- func IsAnyEmpty(ss ...string) bool
- func IsEmpty(s string) bool
- func Join(sep string, ss ...string) string
- func Repeat(s string, count int) string
- func ReplaceAll(s, o, n string) string
- func ToLower(s string) string
- func TrimSpace(s string) string
Constants ¶
const ( // Empty is the empty string constant. Empty = "" // Space is the space string constant. Space = " " )
Variables ¶
This section is empty.
Functions ¶
func Bytes ¶
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 CutColon ¶ added in v2.12.0
CutColon splits s on the first ":" and returns the parts before and after.
If ":" is not present, the returned after value is empty.
func IsAnyEmpty ¶ added in v2.24.0
IsAnyEmpty reports whether any of ss are empty.
func Join ¶
Join joins ss with sep.
This helper allows joining variadic strings without allocating a slice at the callsite.
func ReplaceAll ¶ added in v2.93.0
ReplaceAll is an alias for strings.ReplaceAll.
Types ¶
This section is empty.