strutils

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2019 License: Apache-2.0 Imports: 6 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DictToJSON

func DictToJSON(dict string) string

DictToJSON sanitizes a python dict string representation to valid JSON.

func GetDefaultString

func GetDefaultString(str, def string) string

GetDefaultString returns str if it is not an empty string or def otherwise

func HumanSize

func HumanSize(size int64) string

HumanSize returns the given size (in bytes) in a human readable format

func IsIn added in v0.0.6

func IsIn(str string, lst ...string) bool

IsIn returns true if the given str is the same as one of the strings given in lst

func MakeUnique

func MakeUnique(str string, pool []string) string

MakeUnique returns an unique string in reference of the given pool its made of the base string plus a number if it exists within the pool

func MarshalToJSONString

func MarshalToJSONString(data interface{}) string

MarshalToJSONString marshals the given data to its JSON representation and returns it as a string. It panics in case of error.

func SnakeCase

func SnakeCase(in string) string

SnakeCase convert the given string to snake case following the Golang format: acronyms are converted to lower-case and preceded by an underscore.

func StartsAndEndsWith

func StartsAndEndsWith(str, prefix, suffix string) bool

StartsAndEndsWith returns true if the given string starts with prefix and ends with suffix.

func Substitute

func Substitute(str string, mapping map[string]string) string

Substitute substitutes each occurrence of each key of mapping in str by the corresponding mapping value and returns the substituted string.

func Title

func Title(in string) string

Title convert the given camelCase string to a title string. eg. MyHTMLData => My HTML Data

func TrimArgs added in v0.0.15

func TrimArgs(args []interface{}) []string

TrimArgs returns a slice of string containing every given arg converted to printed string and trimmed down to a length of 30

Types

This section is empty.

Jump to

Keyboard shortcuts

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