strs

package
v0.0.0-...-202847b Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package strs contains additional string manipulation functions.

We cannot name it strings because that name is used by the standard library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CutToLength

func CutToLength(data string, maxLength int) string

CutToLength cuts a long string at maxLength. If shorter, nothing changes.

func FromCamelCase

func FromCamelCase(str string) string

FromCamelCase converts from camel case form to underscore separated form. Eg.: CatalogProductEntity -> catalog_product_entity

func FwordWrap

func FwordWrap(buf io.Writer, s string, lim uint)

FwordWrap same as WordWrap but writes into a buffer.

func IsAlNum

func IsAlNum(s string) bool

IsAlNum returns true if an alpha numeric string consists of characters a-zA-Z0-9_

func LcFirst

func LcFirst(s string) string

LcFirst transforms the first character of a string to lower case.

func LintName

func LintName(name string) (should string)

LintName returns a different name if it should be different. @see github.com/golang/lint/lint.go

func RandAlnum

func RandAlnum(n int) string

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

func ToCamelCase(s string) string

ToCamelCase converts from underscore separated form to camel case form. Eg.: catalog_product_entity -> CatalogProductEntity

func ToGoCamelCase

func ToGoCamelCase(s string) string

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 UcFirst

func UcFirst(s string) string

UcFirst transforms the first character of a string to upper case.

func WordWrap

func WordWrap(s string, lim uint) string

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.

Jump to

Keyboard shortcuts

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