Documentation
¶
Overview ¶
Package convert implements conversions to and from data.
Index ¶
- func BoolToBytes(b bool) []byte
- func BytesToBool(b []byte) bool
- func BytesToFloat64(b []byte) float64
- func BytesToInt16(b []byte) int16
- func BytesToInt32(b []byte) int32
- func BytesToInt64(b []byte) int64
- func BytesToString(b []byte) string
- func BytesToUint32(b []byte) uint32
- func BytesToUint64(b []byte) uint64
- func Float64ToBytes(f float64) []byte
- func Hash(key []byte) uint64
- func HashStr(key string) uint64
- func Int16ToBytes(i int16) []byte
- func Int32ToBytes(i int32) []byte
- func Int64ToBytes(i int64) []byte
- func JSONToString(marshaler json.Marshaler) string
- func ParseSize(sizeStr string) (int64, error)
- func StringToBytes(s string) (b []byte)
- func Uint32ToBytes(u uint32) []byte
- func Uint64ToBytes(u uint64) []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoolToBytes ¶ added in v0.9.0
BoolToBytes converts bool to bytes.
func BytesToBool ¶ added in v0.9.0
BytesToBool converts bytes to bool.
func BytesToFloat64 ¶ added in v0.3.0
BytesToFloat64 converts bytes to float64.
func BytesToInt16 ¶ added in v0.9.0
BytesToInt16 converts a 2-byte slice to int16 using BigEndian.
func BytesToInt32 ¶ added in v0.9.0
BytesToInt32 converts bytes to int32 based on the encoding used in Int32ToBytes.
func BytesToString ¶ added in v0.5.0
BytesToString converts bytes to string. It work well until the referenced memory won’t be changed.
func Float64ToBytes ¶ added in v0.3.0
Float64ToBytes converts float64 to byes.
func Int16ToBytes ¶ added in v0.9.0
Int16ToBytes converts int16 to bytes using BigEndian.
func Int32ToBytes ¶ added in v0.9.0
Int32ToBytes converts int32 to bytes.
func JSONToString ¶ added in v0.7.0
JSONToString converts a JSON marshaler to its JSON string representation.
func ParseSize ¶ added in v0.4.0
ParseSize parses a string like "1.5GB" or "1000" and returns the number of bytes. The following units are supported:
B, K, KB, M, MB, G, GB, T, TB, P, PB KI, KIB, MI, MIB, GI, GIB, TI, TIB, PI, PIB
The units are case insensitive.
func StringToBytes ¶ added in v0.5.0
StringToBytes converts string to bytes. It work well until the referenced memory won’t be changed.
Types ¶
This section is empty.