conv

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: Apache-2.0, MIT Imports: 6 Imported by: 0

Documentation

Overview

Package conv contains functions that help converting data between different types

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(in string) bool

Bool converts a string to a boolean value, using strconv.ParseBool under the covers. Possible true values are: 1, t, T, TRUE, true, True All other values are considered false.

See ToBool also for a more flexible version.

func Dict

func Dict(v ...interface{}) (map[string]interface{}, error)

Dict is a convenience function that creates a map with string keys. Provide arguments as key/value pairs. If an odd number of arguments is provided, the last is used as the key, and an empty string is set as the value. All keys are converted to strings, regardless of input type.

func Has

func Has(in interface{}, key interface{}) bool

Has determines whether or not a given object has a property with the given key

func Join

func Join(in interface{}, sep string) (out string, err error)

Join concatenates the elements of a to create a single string. The separator string sep is placed between elements in the resulting string.

This is functionally identical to strings.Join, except that each element is coerced to a string first

func MustAtoi

func MustAtoi(s string) int

MustAtoi - wrapper for strconv.Atoi that returns 0 in the case of error

func MustParseFloat

func MustParseFloat(s string, bitSize int) float64

MustParseFloat - wrapper for strconv.ParseFloat that returns 0 in the case of error

func MustParseInt

func MustParseInt(s string, base, bitSize int) int64

MustParseInt - wrapper for strconv.ParseInt that returns 0 in the case of error

func MustParseUint

func MustParseUint(s string, base, bitSize int) uint64

MustParseUint - wrapper for strconv.ParseUint that returns 0 in the case of error

func Slice

func Slice(args ...interface{}) []interface{}

Slice creates a slice from a bunch of arguments

func ToBool

func ToBool(in interface{}) bool

ToBool converts an arbitrary input into a boolean. Possible non-boolean true values are: 1 or the strings "t", "true", or "yes" (any capitalizations) All other values are considered false.

func ToBools

func ToBools(in ...interface{}) []bool

ToBools -

func ToFloat64

func ToFloat64(v interface{}) float64

ToFloat64 - convert input to a float64, if convertible. Otherwise, returns 0.

func ToFloat64s

func ToFloat64s(in ...interface{}) []float64

ToFloat64s -

func ToInt

func ToInt(in interface{}) int

ToInt -

func ToInt64

func ToInt64(v interface{}) int64

ToInt64 - convert input to an int64, if convertible. Otherwise, returns 0.

func ToInt64s

func ToInt64s(in ...interface{}) []int64

ToInt64s -

func ToInts

func ToInts(in ...interface{}) []int

ToInts -

func ToString

func ToString(in interface{}) string

ToString -

func ToStrings

func ToStrings(in ...interface{}) []string

ToStrings -

Types

This section is empty.

Jump to

Keyboard shortcuts

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