inflector
import inflector "ganigeorgiev.com/pocketbase/pocketbase/tools/inflector"
Source: tools/inflector.
Functions
Camelize
func Camelize(str string) string
Camelize converts the provided string to its "CamelCased" version (non alphanumeric characters are removed).
For example:
inflector.Camelize("send_email") // "SendEmail"
Columnify
func Columnify(str string) string
Columnify strips invalid db identifier characters.
Sanitize
func Sanitize(str string, removePattern string) (string, error)
Sanitize sanitizes `str` by removing all characters satisfying `removePattern`. Returns an error if the pattern is not valid regex string.
Sentenize
func Sentenize(str string) string
Sentenize converts and normalizes string into a sentence.
Singularize
func Singularize(word string) string
Singularize converts the specified word into its singular version.
For example:
inflector.Singularize("people") // "person"
Snakecase
func Snakecase(str string) string
Snakecase removes all non word characters and converts any english text into a snakecase. "ABBREVIATIONS" are preserved, eg. "myTestDB" will become "my_test_db".
UcFirst
func UcFirst(str string) string
UcFirst converts the first character of a string into uppercase.
Questions and comments
Comments are a GitHub Discussions thread; sign in with GitHub to post.