ftaconv

package
v0.0.0-...-008bdf3 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConvertFail = errors.New("convert data type is failure")
)

Functions

func B2S

func B2S(b []byte) string

B2S converts byte slice to a string without memory allocation. See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .

func BytesToString

func BytesToString(b []byte) string

func CopyBytes

func CopyBytes(b []byte) []byte

CopyBytes returns a copy of byte slice in a new pointer.

func CopySliceString

func CopySliceString(slice []string) []string

CopySliceString returns a copy of the slice.

func CopyString

func CopyString(s string) string

CopyString returns a copy of string in a new pointer.

func EqualBytes

func EqualBytes(a, b []byte) bool

EqualBytes reports whether a and b are the same length and contain the same bytes. A nil argument is equivalent to an empty slice.

func EqualSlicesString

func EqualSlicesString(slice1, slice2 []string) bool

EqualSlicesString checks if the slices are equal.

func ExtendBytes

func ExtendBytes(b []byte, needLen int) []byte

ExtendBytes extends b to needLen bytes.

func Float

func Float(in interface{}) (float64, error)

Float convert value to float64

func IncludeString

func IncludeString(slice []string, s string) bool

IncludeString returns true or false if given string is in slice.

func IndexOfString

func IndexOfString(slice []string, s string) int

IndexOfString returns index position in slice from given string If value is -1, the string does not found.

func Int

func Int(in interface{}) (int, error)

Int convert string to int

func Int64

func Int64(in interface{}) (int64, error)

Int64 convert string to int64

func IsContainCNString

func IsContainCNString(str string) bool

IsContainCNString 判断字符串是否为中文[精确度需要反复试验]

func MustFloat

func MustFloat(in interface{}) float64

MustFloat convert value to float64

func MustInt

func MustInt(in interface{}) int

MustInt convert string to int

func MustInt64

func MustInt64(in interface{}) int64

MustInt64 convert

func MustUint

func MustUint(in interface{}) uint64

MustUint convert string to uint

func PrependBytes

func PrependBytes(dst []byte, src ...byte) []byte

PrependBytes prepends bytes into a given byte slice.

func PrependStringBytes

func PrependStringBytes(dst []byte, src string) []byte

PrependStringBytes prepends a string into a given byte slice.

func RandBytes

func RandBytes(dst []byte) []byte

RandBytes returns dst with a string random bytes Make sure that dst has the length you need.

func ReverseSliceString

func ReverseSliceString(slice []string) []string

ReverseSliceString reverses a string slice.

func ReverseString

func ReverseString(s string) string

ReverseString 反转字符串

func S2B

func S2B(s string) (b []byte)

S2B converts string to a byte slice without memory allocation.

Note it may break if string and/or slice header will change in the future go versions.

func StringToBytes

func StringToBytes(s string) []byte

func ToFloat

func ToFloat(in interface{}) (f64 float64, err error)

ToFloat convert value to float64

func ToInt

func ToInt(in interface{}) (iVal int, err error)

ToInt convert string to int

func ToInt64

func ToInt64(in interface{}) (i64 int64, err error)

ToInt64 convert string to int64

func ToString

func ToString(src interface{}) string

func ToUint

func ToUint(in interface{}) (u64 uint64, err error)

ToUint convert string to uint

func Uint

func Uint(in interface{}) (uint64, error)

Uint convert string to uint

func UniqueAppendString

func UniqueAppendString(slice []string, s ...string) []string

UniqueAppendString appends a string if not exist in the slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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