• Stars
    star
    181
  • Rank 205,151 (Top 5 %)
  • Language
    Go
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Generic and fast binary serializer for Go

Generic and Fast Binary Serializer for Go

This repository contains a fast binary packer for Golang, this allows to encode/decode arbtitrary golang data structures of variable size. Documentation can be found on https://godoc.org/github.com/Kelindar/binary.

This package extends support to arbitrary, variable-sized values by prefixing these values with their varint-encoded size, recursively. This was originally inspired by Alec Thomas's binary package, but I've reworked the serialization format and improved the performance and size. Here's a few notable features/goals of this binary package:

  • Zero-allocation encoding. I'm hoping to make the encoding to be as fast as possible, simply writing binary to the io.Writer without unncessary allocations.
  • Support for maps, arrays, slices, structs, primitive and nested types.
  • This is essentially a json.Marshal and json.Unmarshal drop-in replacement, I wanted this package to be simple to use and leverage the power of reflect package of golang.
  • The ints and uints are encoded using varint, making the payload small as possible.
  • Fast-paths encoding and decoding of []byte, as I've designed this package to be used for inter-broker message encoding for emitter.
  • Support for custom BinaryMarshaler and BinaryUnmarshaler for tighter packing control and built-in types such as time.Time.

Usage

To serialize a message, simply Marshal:

v := &message{
    Name:      "Roman",
    Timestamp: 1242345235,
    Payload:   []byte("hi"),
    Ssid:      []uint32{1, 2, 3},
}

encoded, err := binary.Marshal(v)

To deserialize, Unmarshal:

var v message
err := binary.Unmarshal(encoded, &v)

Disclaimer

This is not intended as a replacement for JSON or protobuf, this codec does not maintain any versioning or compatibility - and not intended to become one. The goal of this binary codec is to efficiently exchange binary data of known format between systems where you control both ends and both of them are written in Go.

More Repositories

1

column

High-performance, columnar, in-memory store with bitmap indexing in Go
Go
1,361
star
2

bitmap

Simple dense bitmap index in Go with binary operators
Assembly
267
star
3

tile

Tile is a 2D grid engine, built with data and cache friendly ways, includes pathfinding and observers.
Go
107
star
4

ecs

Example of Entity Component System in Go
Go
51
star
5

misakai-baker

Baker is a static site generator for C# / .Net people.
C#
41
star
6

demo-chat

A simple chat application built using emitter.io
JavaScript
31
star
7

intmap

Fast integer map for uint32-to-uint32
Go
21
star
8

event

Simple internal event bus for Go applications
Go
18
star
9

gocc

Generate Go Plan9 assembly from C code
Go
18
star
10

lua

Wrapper around LUA script executor for long-running scripts
Go
16
star
11

circular-buffer

An efficient implementation of a resizeable circular byte buffer in C#
C#
15
star
12

spike-build

Spike.Build is the set of libraries that perform parsing and code-generation for creating various client SDKs for Spike Engine.
C#
15
star
13

simd

Package with auto-vectorized math functions for Go
Assembly
13
star
14

stock-explorer

Stock trading tools experiment
Go
13
star
15

xxrand

Fast, scalable pseudo random number generator based on xxh3
Go
10
star
16

smutex

Simple implementation of a sharded mutex in Go
Go
9
star
17

analytics-dashboard

Realtime analytics dashboard of Twitter streaming data using Emitter.
C#
9
star
18

iostream

Simple binary reader and writer
Go
8
star
19

hashbench

Benchmarking hash functions in Go
Go
7
star
20

loader

Golang library that allows for downloading things from a URL (http, s3, ...)
Go
6
star
21

misakai-kafka

Misakai.Kafka is a high performance Apache Kafka client for C#.
C#
6
star
22

twitter-stream

HTML5/C# visualization of a Twitter sample stream in real-time
C#
6
star
23

evolve

Golang implementation of a binary genetic algorithm with random binary crossover & mutation
Go
6
star
24

etop

Command-line utility for emitter.io cluster status.
Go
6
star
25

demo-presence

This demo showcases presence feature of emitter.io
HTML
4
star
26

emitter-cluster

Sample configurations for emitter cluster
4
star
27

emitter-actor

Example of an Actor Model built with Emitter
Go
3
star
28

tcp

Simple tcp server in Go
Go
3
star
29

spike-box

A modern experimental web server with browser DOM to server-side javascript data binding.
JavaScript
3
star
30

docker

Various docker repositories for automated build.
Perl
3
star
31

markov

Simple Markov chain implementation
Go
3
star
32

buddy

Buddy memory allocator for hashed strings in Go
Go
3
star
33

simplex

Simplex noise in Go
Go
3
star
34

demo-paint

Collaborative paint demo for emitter.io
JavaScript
2
star
35

spiral

Generating spiral galaxy shape
Go
2
star
36

demo-microservice

Demo of emitter.io enabling a web application using docker, rancher and a set of microservices
JavaScript
1
star
37

emitter-client-server

Demo of a client-server app with Emitter & Go
Go
1
star
38

process

Golang library for process usage retrieval
Go
1
star
39

http-echo

This is a simple HTTP echo server which fails from time to time. Perfect to learn resiliency.
Go
1
star
40

pmml2lua

POC for converting PMML to LUA
Go
1
star
41

awesome-go-storage

A curated list of awesome Go storage projects and libraries
1
star
42

zmachine

Converting a Z-Machine in Go to an online system
Go
1
star
43

blog

1
star
44

metering

This metering plugin for emitter.io broker persists usage in Google Datastore.
Go
1
star