strconvutil

package
v0.64.3 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MIT Imports: 11 Imported by: 29

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrValueIsNegative = errors.New("value is negative")
View Source
var RxPlus = regexp.MustCompile(`^\+`)

Functions

func Atof added in v0.63.8

func Atof(s string, bitSizeIs32 bool) (float64, error)

func AtofFunc added in v0.63.8

func AtofFunc(funcStringToFloat func(s string) (float64, error), s string) (float64, error)

func AtofMore added in v0.63.8

func AtofMore(s string, bitSizeIs32 bool, comma string) (float64, error)

func Atoi16 added in v0.37.1

func Atoi16(s string) (int16, error)

func Atoi32 added in v0.37.1

func Atoi32(s string) (int32, error)

func Atoi8 added in v0.37.1

func Atoi8(s string) (int8, error)

func AtoiFunc added in v0.63.8

func AtoiFunc(funcStringToInt64 func(s string) (int, error), s string) (int, error)

func AtoiLang

func AtoiLang(lang, s string) (int, error)

AtoiLang provides language parsing to handle thousands separators. Number formats: https://docs.oracle.com/cd/E19455-01/806-0169/overview-9/index.html

func AtoiMore added in v0.39.0

func AtoiMore(s, comma, decimal string) (int, error)

func AtoiMoreFunc added in v0.63.8

func AtoiMoreFunc(comma, decimal string) func(s string) (int, error)

func AtoiOrDefault

func AtoiOrDefault(s string, def int) int

AtoiOrDefault is like Atoi but takes a default value which it returns in the event of a parse error.

func Atou added in v0.61.0

func Atou(s string) (uint, error)

func Btoa added in v0.64.3

func Btoa(b bool) string

Btoa returns "true" or "false" according to the value of b.

func CanonicalIntStringOrIgnore added in v0.39.0

func CanonicalIntStringOrIgnore(s, comma, decimal string) string

func ChangeToFunnelPct

func ChangeToFunnelPct(f float64) float64

ChangeToFunnelPct converts a 1.0 == 100% based `float64` to a Funnel percentage `float64`.

func ChangeToXoXPct

func ChangeToXoXPct(f float64) float64

ChangeToXoXPct converts a 1.0 == 100% based `float64` to a XoX percentage `float64`.

func Commify

func Commify(n int64) string

Commify takes an int64 and adds comma for every thousand

func DecimalSeparator

func DecimalSeparator(lang string) (string, error)

func FormatBoolMore added in v0.55.0

func FormatBoolMore(b bool, trueVal, falseVal string) string

func FormatDecimal added in v0.42.0

func FormatDecimal[N constraints.Float | constraints.Integer](v N, precision int) string

func FormatFloat64ToAnyString

func FormatFloat64ToAnyString(f float64, pattern string) string

FormatFloat64ToAnyString is used for XoX growth.

func FormatFloat64ToAnyStringFunnel

func FormatFloat64ToAnyStringFunnel(f float64, pattern string) string

FormatFloat64ToAnyStringFunnel is used for funnels.

func FormatFloat64ToIntString

func FormatFloat64ToIntString(f float64) string

func FormatFloat64ToIntStringFunnel

func FormatFloat64ToIntStringFunnel[F constraints.Float](f F) string

func Ftoa added in v0.63.1

func Ftoa[F constraints.Float](f F) string

func Int64Abbreviation

func Int64Abbreviation(val int64) string

Int64Abbreviation returns integer abbreviations. For example, "1.5K", "15K", "150K", "1.5M", "15M", "150M".

func Int64Len

func Int64Len(val int64) int

Int64Len returns the length of an Int64 number.

func Itoa added in v0.50.0

func Itoa[E constraints.Integer](e E) string

Itoa is like `strconv.Itoa()` with the additional functionality of converting `uint64` and accepting integer types natively via `constraints.Integer`.

func MustParseBool

func MustParseBool(s string) bool

func MustParseE164ToInt

func MustParseE164ToInt(s string) int

func MustParseInt

func MustParseInt(s string) int

func SliceAtof added in v0.63.0

func SliceAtof(s []string, bitSize int) ([]float64, error)

func SliceAtoi

func SliceAtoi(s []string, dedupe, sort bool) ([]int, error)

SliceAtoi converts a slice of string integers.

func SliceAtotFunc added in v0.63.8

func SliceAtotFunc(funcFormat func(s string) (time.Time, error), s []string) ([]time.Time, error)

func SliceAtou added in v0.61.1

func SliceAtou(s []string, dedupe, sort bool) ([]uint, error)

func SliceItoa

func SliceItoa[S ~[]E, E constraints.Integer](s S) []string

SliceItoa converts a slice of `constraints.Integer` to a slice of `string`.

func SliceItoaMore added in v0.63.1

func SliceItoaMore[S ~[]E, E constraints.Integer](s S, dedupe, sort bool) []string

SliceItoaMore converts a slice of `constraints.Integer` to a slice of `string` with additional functionality to dedupe and sort.

func ThousandsSeparator

func ThousandsSeparator(lang string) (string, error)

func UnquoteMore added in v0.56.0

func UnquoteMore(s string) (string, error)

UnquoteMore wraps `strconv.Unquote()` with additional functionality of allowing more chracters within single quotes.`

func UnquoteMoreOrNot added in v0.56.0

func UnquoteMoreOrNot(s string) string

UnquoteMoreOrNot wraps `UnquoteMore()`

Types

type Float64ToString

type Float64ToString func(float64) string

Float64ToString is a function type to define functions.

type Int64ToString

type Int64ToString func(int64) string

Int64ToString is a function type to define functions.

Jump to

Keyboard shortcuts

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