stringutils

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConsumePrefix

func ConsumePrefix(s *string, prefix string) bool

ConsumePrefix checks if *s has the given prefix, and if yes, modifies it to remove the prefix. The return value indicates whether the original string had the given prefix.

func ConsumeSuffix

func ConsumeSuffix(s *string, suffix string) bool

ConsumeSuffix checks if *s has the given suffix, and if yes, modifies it to remove the suffix. The return value indicates whether the original string had the given suffix.

func OrDefault

func OrDefault(s, defaultValue string) string

OrDefault returns the string if it's not empty, or the default.

func PointerOrDefault

func PointerOrDefault(s *string, defaultValue string) string

PointerOrDefault returns the string if it's not nil nor empty, or the default.

func Repeat

func Repeat(s string, n int) string

Repeat repeats the given string `n` times efficiently.

func Split2

func Split2(str, sep string) (string, string)

Split2 splits the given string at the given separator, returning the part before and after the separator as two separate return values. If the string does not contain `sep`, the entire string is returned as the first return value.

func Ternary

func Ternary(condition bool, ifTrue, ifFalse string) string

Ternary does a ternary based on the condition.

Types

This section is empty.

Jump to

Keyboard shortcuts

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