xstrings

package module
v0.0.0-...-4dd8b23 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: MIT Imports: 5 Imported by: 8 modules, 7 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

github.com/lestrrat-go/xstrings Go reference codecov.io

Unicode-aware string utilities for Go

DESCRIPTION

Many string utilities available on the web only work with characters in ASCII range. This library does The Right Thing and goes through the proper unicode / unicode/utf8 decoding routines before processing the strings

AVAILABLE FUNCTIONS

Name Description
LcFirst(string) string Converts first rune of string to lower case
UcFirst(string) string Converts first rune of string to upper case
Snake(string, SnakeOptions...) Converts a string into snake_case. Supports alternate delimiters and SCREAMING case via options
Camel(string, CamelOptions...) Converts a string into CamelCase. Supports lowerCaseCame via options
FirstNRunes(strings, int) Returns a strings consisting of the first N runes in the string

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Camel

func Camel(s string, options ...CamelOption) string

func FirstNRunes

func FirstNRunes(s string, n int) string

Returns the string consisting of the first `n` runes found.

It is the caller's responsibility to ensure that the string contains valid runes throughout. If a rune cannot be decoded, utf8.RuneError will be used in its place.

If `n` exceeds the number of runes in string `s`, `s` is returned unmodified.

func LcFirst

func LcFirst(s string) string

LcFirst returns a string with the first rune in upper case. If for any reason we fail to decode the first rune in the string, the same string is returned instead of an error.

func Snake

func Snake(s string, options ...SnakeOption) string

func UcFirst

func UcFirst(s string) string

UcFirst returns a string with the first rune in upper case. If for any reason we fail to decode the first rune in the string, the same string is returned instead of an error.

Types

type CamelOption

type CamelOption interface {
	Option
	// contains filtered or unexported methods
}

func WithLowerCamel

func WithLowerCamel(v bool) CamelOption

WithLowerCamel specifies that the first letter of a camel cased string should be lower cased

type Option

type Option = option.Interface

type SnakeOption

type SnakeOption interface {
	Option
	// contains filtered or unexported methods
}

func WithDelimiter

func WithDelimiter(r rune) SnakeOption

WithDelimiter allows you to change the delimiter used in snake case coversion

func WithScreaming

func WithScreaming(v bool) SnakeOption

WithScreaming specifies that the conversion to snake case should produce words in all uppercase (e.g. SNAKE_CASE)

Jump to

Keyboard shortcuts

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