gconv

package
v0.0.0-...-14c708c Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package gconv implements powerful and easy-to-use converting functionality for any types of variables.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(i interface{}) bool

Bool converts <i> to bool. It returns false if <i> is: false, "", 0, "false", "off", "no", empty slice/map.

func Byte

func Byte(i interface{}) byte

Byte converts <i> to byte.

func Bytes

func Bytes(i interface{}) []byte

Bytes converts <i> to []byte.

func Convert

func Convert(i interface{}, t string, params ...interface{}) interface{}

Convert converts the variable <i> to the type <t>, the type <t> is specified by string. The optional parameter <params> is used for additional necessary parameter for this conversion. It supports common types conversion as its conversion based on type name string.

func Float32

func Float32(i interface{}) float32

Float32 converts <i> to float32.

func Float32s

func Float32s(i interface{}) []float32

Float32s converts <i> to []float32.

func Float64

func Float64(i interface{}) float64

Float64 converts <i> to float64.

func Float64s

func Float64s(i interface{}) []float64

Float64s converts <i> to []float64.

func Floats

func Floats(i interface{}) []float64

Floats converts <i> to []float64.

func Int

func Int(i interface{}) int

Int converts <i> to int.

func Int16

func Int16(i interface{}) int16

Int16 converts <i> to int16.

func Int32

func Int32(i interface{}) int32

Int32 converts <i> to int32.

func Int32s

func Int32s(i interface{}) []int32

Int32s converts <i> to []int32.

func Int64

func Int64(i interface{}) int64

Int64 converts <i> to int64.

func Int64s

func Int64s(i interface{}) []int64

Int64s converts <i> to []int64.

func Int8

func Int8(i interface{}) int8

Int8 converts <i> to int8.

func Interfaces

func Interfaces(i interface{}) []interface{}

Interfaces converts <i> to []interface{}.

func Ints

func Ints(i interface{}) []int

Ints converts <i> to []int.

func IsArray

func IsArray(value interface{}) bool

IsArray checks whether given value is array/slice. Note that it uses reflect internally implementing this feature.

func IsEmpty

func IsEmpty(value interface{}) bool

IsEmpty checks whether given <value> empty. It returns true if <value> is in: 0, nil, false, "", len(slice/map/chan) == 0. Or else it returns true.

func IsLetterLower

func IsLetterLower(b byte) bool

IsLetterLower tests whether the given byte b is in lower case.

func IsLetterUpper

func IsLetterUpper(b byte) bool

IsLetterUpper tests whether the given byte b is in upper case.

func IsNil

func IsNil(value interface{}) bool

IsNil checks whether given <value> is nil. Note that it might use reflect feature which affects performance a little bit.

func IsNumeric

func IsNumeric(s string) bool

IsNumeric tests whether the given string s is numeric. Note that float string like "123.456" is also numeric.

func ReplaceByMap

func ReplaceByMap(origin string, replaces map[string]string) string

ReplaceByMap returns a copy of <origin>, which is replaced by a map in unordered way, case-sensitively.

func Rune

func Rune(i interface{}) rune

Rune converts <i> to rune.

func Runes

func Runes(i interface{}) []rune

Runes converts <i> to []rune.

func SliceAny

func SliceAny(i interface{}) []interface{}

SliceAny is alias of Interfaces.

func SliceFloat

func SliceFloat(i interface{}) []float64

SliceFloat is alias of Floats.

func SliceFloat32

func SliceFloat32(i interface{}) []float32

SliceFloat32 is alias of Float32s.

func SliceFloat64

func SliceFloat64(i interface{}) []float64

SliceFloat64 is alias of Float64s.

func SliceInt

func SliceInt(i interface{}) []int

SliceInt is alias of Ints.

func SliceInt32

func SliceInt32(i interface{}) []int32

SliceInt32 is alias of Int32s.

func SliceInt64

func SliceInt64(i interface{}) []int64

SliceInt is alias of Int64s.

func SliceStr

func SliceStr(i interface{}) []string

SliceStr is alias of Strings.

func SliceUint

func SliceUint(i interface{}) []uint

SliceUint is alias of Uints.

func SliceUint32

func SliceUint32(i interface{}) []uint32

SliceUint32 is alias of Uint32s.

func SliceUint64

func SliceUint64(i interface{}) []uint64

SliceUint64 is alias of Uint64s.

func String

func String(i interface{}) string

String converts <i> to string. It's most common used converting function.

func Strings

func Strings(i interface{}) []string

Strings converts <i> to []string.

func UcFirst

func UcFirst(s string) string

UcFirst returns a copy of the string s with the first letter mapped to its upper case.

func Uint

func Uint(i interface{}) uint

Uint converts <i> to uint.

func Uint16

func Uint16(i interface{}) uint16

Uint16 converts <i> to uint16.

func Uint32

func Uint32(i interface{}) uint32

Uint32 converts <i> to uint32.

func Uint32s

func Uint32s(i interface{}) []uint32

Uint32s converts <i> to []uint32.

func Uint64

func Uint64(i interface{}) uint64

Uint64 converts <i> to uint64.

func Uint64s

func Uint64s(i interface{}) []uint64

Uint64s converts <i> to []uint64.

func Uint8

func Uint8(i interface{}) uint8

Uint8 converts <i> to uint8.

func Uints

func Uints(i interface{}) []uint

Uints converts <i> to []uint.

func UnsafeBytesToStr

func UnsafeBytesToStr(b []byte) string

UnsafeBytesToStr converts []byte to string without memory copy. Note that, if you completely sure you will never use <s> in the feature, you can use this unsafe function to implement type conversion in high performance.

func UnsafeStrToBytes

func UnsafeStrToBytes(s string) []byte

UnsafeStrToBytes converts string to []byte without memory copy. Note that, if you completely sure you will never use <s> in the feature, you can use this unsafe function to implement type conversion in high performance.

Types

This section is empty.

Jump to

Keyboard shortcuts

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