gstrings

package
v0.0.0-...-5e380c2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Find

func Find(needle string, haystack []string) int

Find returns the index of the needle in the haystack (has to match exactly) or returns -1 if the needles wasn't found

func FindCust

func FindCust(needle string, haystack []string, custCompare func(string, string) bool) int

FindCust returns the idnex of the needle in the haystack (has to match according to the custCompare function) or returns -1 if the needles wasn't found

func MatchingProblem

func MatchingProblem(obj, i1, i2 interface{}) string

MatchingProblem returns a formatted string which explains that the two elements s1 and s2 of type obj don't match

func ReplaceAnyBetween

func ReplaceAnyBetween(s, start, end, old, new string) string

ReplaceAnyBetween replaces in s only 'old' between start and end for 'new' e.g. "asdf{{hehe}}ff" -(start:}},end:}},old:ha,new:ho)-> "asdf{{hoho}}ff"

func ReplaceFuncBetween

func ReplaceFuncBetween(s, start, end string, rpl ReplaceFunc) string

ReplaceFuncBetween is similar to ReplaceAnyBetween. It looks through the string, and replaces the string between start and end with the ReplaceFunc.

func SetIfExists

func SetIfExists(dst *string, src string)

SetIfExists does dst = src (only if src is not empty)

func StringBetween

func StringBetween(s, start, end string) (found bool, str string)

StringBetween returns a string enclosed by start and end (excluded both)

func ToCamel

func ToCamel(s string, sep rune, capitalize bool) string

ToCamel formats string s into camel case from snake case with specified rune e.g. hi_im_camel -> hiImCamel

func ToSnake

func ToSnake(s string) string

ToSnake formats string s into snake_case from CamelCase

Types

type ReplaceFunc

type ReplaceFunc func(string) string

ReplaceFunc is the type of a function which takes a string and replaces what it wants, then returns it

Jump to

Keyboard shortcuts

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