objectpacker

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: GPL-2.0 Imports: 8 Imported by: 0 modules, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustPackSlice

func MustPackSlice(items ...interface{}) []byte

MustPackSlice calls PackAny using items and panics if there was an error.

func PackAny

func PackAny(in interface{}, out io.Writer) error

PackAny packs any JSON-encodable value (ex. structs, also ignores interfaces like encoding.TextMarshaler) to a BSON-similar format suitable for consistent hashing. Spec:

PackAny(nil) => 0x0 PackAny(false) => 0x1 PackAny(true) => 0x2 PackAny(float64(42)) => 0x3 ieee754_binary64_bigendian(42) PackAny("exämple") => 0x4 uint64_bigendian(len([]byte("exämple"))) []byte("exämple") PackAny([]uint8{0x42}) => 0x4 uint64_bigendian(len([]uint8{0x42})) []uint8{0x42} PackAny([1]uint8{0x42}) => 0x4 uint64_bigendian(len([1]uint8{0x42})) [1]uint8{0x42} PackAny([]T{x,y}) => 0x5 uint64_bigendian(len([]T{x,y})) PackAny(x) PackAny(y) PackAny(map[K]V{x:y}) => 0x6 uint64_bigendian(len(map[K]V{x:y})) len(map_key(x)) map_key(x) PackAny(y) PackAny((*T)(nil)) => 0x0 PackAny((*T)(0x42)) => PackAny(*(*T)(0x42)) PackAny(x) => panic()

map_key([1]uint8{0x42}) => [1]uint8{0x42} map_key(x) => []byte(fmt.Sprint(x))

Types

This section is empty.

Jump to

Keyboard shortcuts

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