stringutil

package
v0.0.0-...-dbcdc5d Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteSlice2String

func ByteSlice2String(b []byte) string

ByteSlice2String converts a byte slice into a string without a heap allocation. Be aware that the byte slice and the string share the same memory - which makes the string mutable.

func FieldsN

func FieldsN(s string, f []string) int

FieldsN splits the string s around each instance of one or more consecutive space characters, filling f with substrings of s. If s contains more fields than n, the last element of f is set to the unparsed remainder of s starting with the first non-space character. f will stay untouched if s is empty or contains only white space. if n is greater than len(f), 0 is returned without doing any parsing.

Apart from the mentioned differences, FieldsN is like an allocation-free strings.Fields.

func SplitN

func SplitN(s, sep string, f []string) int

SplitN splits the string around each instance of sep, filling f with substrings of s. If s contains more fields than n, the last element of f is set to the unparsed remainder of s starting with the first non-space character. f will stay untouched if s is empty or contains only white space. if n is greater than len(f), 0 is returned without doing any parsing.

Apart from the mentioned differences, SplitN is like an allocation-free strings.SplitN.

Types

This section is empty.

Jump to

Keyboard shortcuts

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