Documentation ¶
Overview ¶
Package strs contains additional string manipulation functions.
We cannot name it strings because that name is used by the standard library.
Index ¶
- func CutToLength(data string, maxLength int) string
- func FromCamelCase(str string) string
- func FwordWrap(buf io.Writer, s string, lim uint)
- func IsAlNum(s string) bool
- func LintName(name string) (should string)
- func RandAlnum(n int) string
- func ToCamelCase(s string) string
- func ToGoCamelCase(s string) string
- func WordWrap(s string, lim uint) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CutToLength ¶
CutToLength cuts a long string at maxLength. If shorter, nothing changes.
func FromCamelCase ¶
FromCamelCase converts from camel case form to underscore separated form. Eg.: CatalogProductEntity -> catalog_product_entity
func LintName ¶
LintName returns a different name if it should be different. @see github.com/golang/lint/lint.go
func RandAlnum ¶
RandAlnum returns a random string with a defined length n of alpha numerical characters. This function does not use the global rand variable from math/rand package.
func ToCamelCase ¶
ToCamelCase converts from underscore separated form to camel case form. Eg.: catalog_product_entity -> CatalogProductEntity
func ToGoCamelCase ¶
ToGoCamelCase transforms from snake case to CamelCase. Also removes quotes and takes care of special names.
idx_eav_id => IDXEAVID hello_gopher_id => HelloGopherID catalog_product_entity => CatalogProductEntity
func WordWrap ¶
Wordwrap wraps the given string within lim width in characters.
Wrapping is currently naive and only happens at white-space. A future version of the library will implement smarter wrapping. This means that pathological cases can dramatically reach past the limit, such as a very long word.
The primary use case for this is in formatting CLI output, but of course word wrapping is a generally useful thing to do.
Types ¶
This section is empty.