convert

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package convert implements conversions to and from data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendFloat64Bytes added in v0.11.0

func AppendFloat64Bytes(dst []byte, f float64) []byte

AppendFloat64Bytes appends the big-endian IEEE-754 representation of f to dst.

func BoolToBytes added in v0.9.0

func BoolToBytes(b bool) []byte

BoolToBytes converts bool to bytes.

func BytesToBool added in v0.9.0

func BytesToBool(b []byte) bool

BytesToBool converts bytes to bool.

func BytesToFloat64 added in v0.3.0

func BytesToFloat64(b []byte) float64

BytesToFloat64 converts bytes to float64.

func BytesToInt16 added in v0.9.0

func BytesToInt16(b []byte) int16

BytesToInt16 converts a 2-byte slice to int16 using BigEndian.

func BytesToInt32 added in v0.9.0

func BytesToInt32(b []byte) int32

BytesToInt32 converts bytes to int32 based on the encoding used in Int32ToBytes.

func BytesToInt64

func BytesToInt64(b []byte) int64

BytesToInt64 converts bytes to int64.

func BytesToString added in v0.5.0

func BytesToString(b []byte) string

BytesToString converts bytes to string. It works well until the referenced memory won’t be changed.

func BytesToUint32

func BytesToUint32(b []byte) uint32

BytesToUint32 converts bytes to uint32.

func BytesToUint64

func BytesToUint64(b []byte) uint64

BytesToUint64 converts bytes to uint64.

func Float64ToBytes added in v0.3.0

func Float64ToBytes(f float64) []byte

Float64ToBytes converts float64 to bytes.

func Float64ToOrderedBytes added in v0.11.0

func Float64ToOrderedBytes(f float64) []byte

Float64ToOrderedBytes converts float64 to bytes with order-preserving encoding. This ensures that byte comparison matches numeric comparison for sorting purposes.

func Hash

func Hash(key []byte) uint64

Hash computes the 64-bit Hash digest of key.

func HashStr

func HashStr(key string) uint64

HashStr computes the 64-bit Hash digest of key.

func Int16ToBytes added in v0.9.0

func Int16ToBytes(i int16) []byte

Int16ToBytes converts int16 to bytes using BigEndian.

func Int32ToBytes added in v0.9.0

func Int32ToBytes(i int32) []byte

Int32ToBytes converts int32 to bytes.

func Int64ToBytes

func Int64ToBytes(i int64) []byte

Int64ToBytes converts int64 to bytes.

func JSONToString added in v0.7.0

func JSONToString(marshaler json.Marshaler) string

JSONToString converts a JSON marshaler to its JSON string representation.

func OrderedBytesToFloat64 added in v0.11.0

func OrderedBytesToFloat64(b []byte) float64

OrderedBytesToFloat64 converts bytes to float64 with order-preserving decoding.

func ParseSize added in v0.4.0

func ParseSize(sizeStr string) (int64, error)

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

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

StringToBytes converts string to bytes. It works well until the referenced memory won’t be changed.

func Uint32ToBytes

func Uint32ToBytes(u uint32) []byte

Uint32ToBytes converts uint32 to bytes.

func Uint64ToBytes

func Uint64ToBytes(u uint64) []byte

Uint64ToBytes converts uint64 to bytes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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