stringutil

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CutLast added in v0.0.3

func CutLast(s, sep string) (before, after string, found bool)

CutLast is strings.Cut, but cutting at the last occurrence of sep rather than the first.

func CutPrefix

func CutPrefix(s, prefix string) (after string, found bool)

CutPrefix behaves like strings.Cut, but only cuts a prefix, not anywhere in the string.

func CutSuffix added in v0.0.3

func CutSuffix(s, suffix string) (before string, found bool)

CutSuffix behaves like strings.Cut, but only cuts a suffix, not anywhere in the string.

func CutTwice

func CutTwice(s, sep1, sep2 string) (before, between, after string, found bool)

CutTwice calls strings.Cut twice to split s into three strings. If either separator isn't found in s, returns s, "", "", false.

func ReadJSONFile

func ReadJSONFile(path string, i interface{}) (err error)

ReadJSONFile reads one JSON value from the specified file. Supports BOM.

func WriteJSONFile

func WriteJSONFile(path string, i interface{}) (err error)

WriteJSONFile writes one specified value to a file as indented JSON with a trailing newline.

Types

This section is empty.

Jump to

Keyboard shortcuts

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