take bytes out of things easily ✨🍪

cookie with a bite taken out of it
crunch

a library for easily manipulating bits and bytes in golang

license godoc travis codecov go report card try it on repl.it

features | installation | benchmarks | examples

features

  • feature-rich: supports reading and writing integers of varying sizes in both little and big endian
  • performant: performs more than twice as fast as the standard library's bytes.Buffer
  • simple and familiar: has a consistent and easy-to-use api
  • licensed under the mpl-2.0: use it anywhere you wish, just don't change it privately

installation

install with the go tool

$ go get github.com/superwhiskers/crunch/v3

then, just import it in your project like this. easy!

package "yourpackage"

import crunch "github.com/superwhiskers/crunch/v3"

install using git submodules (not recommended)

# this assumes that you are in a git repository
$ git submodule add https://github.com/superwhiskers/crunch path/to/where/you/want/crunch

then, you can import it like this

package "yourpackage"

import crunch "github.com/your-username/project/path/to/crunch/v3"

benchmarks

both Buffer and MiniBuffer perform on average more than twice as fast as bytes.Buffer in both writing and reading

BenchmarkBufferWriteBytes-4             2000000000               1.45 ns/op            0 B/op          0 allocs/op
BenchmarkBufferReadBytes-4              2000000000               0.84 ns/op            0 B/op          0 allocs/op
BenchmarkBufferWriteU32LE-4             200000000                9.28 ns/op            0 B/op          0 allocs/op
BenchmarkBufferReadU32LE-4              50000000                26.6 ns/op             8 B/op          1 allocs/op
BenchmarkBufferReadBit-4                2000000000               0.84 ns/op            0 B/op          0 allocs/op
BenchmarkBufferReadBits-4               1000000000               2.25 ns/op            0 B/op          0 allocs/op
BenchmarkBufferSetBit-4                 1000000000               2.07 ns/op            0 B/op          0 allocs/op
BenchmarkBufferClearBit-4               1000000000               2.05 ns/op            0 B/op          0 allocs/op
BenchmarkMiniBufferWriteBytes-4         2000000000               1.42 ns/op            0 B/op          0 allocs/op
BenchmarkMiniBufferReadBytes-4          2000000000               0.58 ns/op            0 B/op          0 allocs/op
BenchmarkMiniBufferWriteU32LE-4         200000000                8.79 ns/op            0 B/op          0 allocs/op
BenchmarkMiniBufferReadU32LE-4          500000000                3.91 ns/op            0 B/op          0 allocs/op
BenchmarkMiniBufferReadBit-4            2000000000               0.64 ns/op            0 B/op          0 allocs/op
BenchmarkMiniBufferReadBits-4           300000000                5.64 ns/op            0 B/op          0 allocs/op
BenchmarkMiniBufferSetBit-4             1000000000               2.03 ns/op            0 B/op          0 allocs/op
BenchmarkMiniBufferClearBit-4           1000000000               2.10 ns/op            0 B/op          0 allocs/op
BenchmarkStdByteBufferWrite-4           200000000                9.42 ns/op            0 B/op          0 allocs/op
BenchmarkStdByteBufferRead-4            500000000                3.36 ns/op            0 B/op          0 allocs/op

examples

examples can be found in the examples directory

acknowledgements

icon (cookie logo) made by freepik from flaticon.com

Similar Resources

An IPFS bytes exchange for caching and retrieving data from Filecoin

🐸 go-hop-exchange An IPFS bytes exchange to allow any IPFS node to become a Filecoin retrieval provider and retrieve content from Filecoin Highlights

Aug 25, 2022

A tiny date object in Go. Tinydate uses only 4 bytes of memory

go-tinydate A tiny date object in Go. Tinydate uses 4 bytes of memory vs the 24 bytes of a standard time.Time{} A tinydate only has day precision. It

Mar 17, 2022

Segment tree for bytes in Go

bsegtree Segment tree for bytes in Go Based on Thomas Oberndörfer's int range segment tree with fixing/optimization/modification for bytes ranges. For

Jun 16, 2022

PKSUID is a small extension for KSUID (K-Sortable Globally Unique IDs) which allows prefixing it with arbitrary up to 16 bytes strings

PKSUID is a small extension for KSUID (K-Sortable Globally Unique IDs) which allows prefixing it with arbitrary up to 16 bytes strings

Dec 1, 2022

A utility library to do files/io/bytes processing/parsing in file-system or network.

goreader A utility library to do files/io/bytes processing/parsing in file-system or network. These features are really common to be implemented for a

Nov 1, 2021

Encode (structured and unstructured) data via bytes

Go Bytes Go A simple encoding lib to print/parse structured and unstructured data over a non self-describing bytestream. This lib will use the include

Jan 8, 2022

File-generator - Creates a file filled with bytes

creates a file filled with bytes ./filegen from to from : index of first piece t

Feb 14, 2022

A logr LogSink implementation using bytes.Buffer

buflogr A logr LogSink implementation using bytes.Buffer. Usage import ( "bytes" "fmt" "github.com/go-logr/logr" "github.com/tonglil/buflogr" )

Jan 6, 2023

A small drunken bishop written in Go to represent bytes.

Go, Little Drunken Bishop! go get github.com/eloonstra/go-little-drunken-bishop Table of Contents How does it work? Usage Example License Contributin

Mar 13, 2022

Print random bytes from a secure source to stdout.

Print random bytes from a secure source to stdout.

Feb 11, 2022

A Go library that provides functions for bytes and bits.

Byteman A Golang library that provides functions for bytes and bits. Usage See byteman_test.go, numbers_test.go and strings_test.go. Test # Test every

Apr 19, 2022

A Go package to allow you to read and write from the serial port as a stream of bytes.

Serial A Go package to allow you to read and write from the serial port as a stream of bytes. Details It aims to have the same API on all platforms, i

Jan 6, 2023

Take control of your data, connect with anything, and expose it anywhere through protocols such as HTTP, GraphQL, and gRPC.

Take control of your data, connect with anything, and expose it anywhere through protocols such as HTTP, GraphQL, and gRPC.

Semaphore Chat: Discord Documentation: Github pages Go package documentation: GoDev Take control of your data, connect with anything, and expose it an

Sep 26, 2022

Demonstrating how you can take an action to your intrusions detected by Falco using OpenFaaS functions

Demonstrating how you can take an action to your intrusions detected by Falco using OpenFaaS functions

Kubernetes Response Engine powered by OpenFaaS Although Falco can be used to detect any intrusion attempts and sends alerts to channels according to t

Aug 22, 2022

Take screenshots of websites and create PDF from HTML pages using chromium and docker

gochro is a small docker image with chromium installed and a golang based webserver to interact wit it. It can be used to take screenshots of w

Nov 23, 2022

Take a list of domains and scan for endpoints, secrets, api keys, file extensions, tokens and more...

Take a list of domains and scan for endpoints, secrets, api keys, file extensions, tokens and more...

Take a list of domains and scan for endpoints, secrets, api keys, file extensions, tokens and more... Coded with 💙 by edoardottt. Share on Twitter! P

Dec 25, 2022

Take an IP address and quickly get the reverse PTR

FlipIP Just a little quick app to take an IP (or set of IPs), and convert them to reverse IP pointers Example: $ flipip 1.2.3.4 4.3.2.1.in-addr.arpa.

Feb 27, 2022

Cook amazing genetic parts using our cookbook. Recipes and synthetic biology tools to take your breath away.

friendzymes-cookbook Friendly tools for a friendly community. A collection of tutorials and genetic tools for synthetic biology. This cookbook is a su

Aug 19, 2022

A simple CLI app to take notes daily on markdown file

A simple CLI app to take notes daily on markdown file

A simple CLI app to take notes daily on markdown file

Jul 29, 2022
Comments
  •  Fix misuse of unsafe.Pointer in buffer.go

    Fix misuse of unsafe.Pointer in buffer.go

    According to: https://golang.org/pkg/unsafe/#Pointer

    Usage of unsafe.Pointer should be implemented with defined pattern to avoid becoming invalid in the future.

  • Fix misuse of unsafe.Pointer in minibuf.go

    Fix misuse of unsafe.Pointer in minibuf.go

    According to: https://golang.org/pkg/unsafe/#Pointer

    Usage of unsafe.Pointer should be implemented with defined pattern to avoid becoming invalid in the future.

Simple code just to try out and Binary Tree on Golang.

Character counter | ▮▮▮▮▮▮▮▮ Simple code just to try out and Binary Tree on Golang. Count characters to train openning a file and reading it, as well

May 17, 2022
TBH, there are probably better/faster implementations out there.

Scott's Skiplist TBH, there are probably better/faster implementations out there. See https://github.com/MauriceGit/skiplist-survey I wrote this one b

Feb 10, 2022
parse and generate XML easily in go

etree The etree package is a lightweight, pure go package that expresses XML in the form of an element tree. Its design was inspired by the Python Ele

Dec 30, 2022
Time struct in Go that uses 4 bytes of memory vs the 24 bytes of time.Time

A tiny time object in Go. Tinytime uses 4 bytes of memory vs the 24 bytes of a standard time.Time{}

Oct 3, 2022
Take control over your live stream video by running it yourself. Streaming + chat out of the box.
Take control over your live stream video by running it yourself.  Streaming + chat out of the box.

Take control over your content and stream it yourself. Explore the docs » View Demo · Use Our Server for Testing · FAQ · Report Bug Table of Contents

Jan 1, 2023
Fonts is a package that provides helpers to access font details and easily retrive font bytes with ZERO dependencies

Fonts Fonts is a package that provides helpers to access font details and easily retrieve font bytes. This package has ZERO 3rd-party dependencies. Fo

Mar 3, 2022
Easily and securely send things from one computer to another :crocodile: :package:
Easily and securely send things from one computer to another :crocodile: :package:

This project is supported by: croc is a tool that allows any two computers to simply and securely transfer files and folders. AFAIK, croc is the only

Jan 3, 2023
In 'n Out - See what goes in and comes out of PEs/DLLs

In 'n Out Parse and return PE information ino -v comsvcs.dll { "Name": "<string>", "Path": "<string>", "Type": "<string file|directory>", "Im

Dec 16, 2022
Issue-mafia - An out-of-the-box CLI that helps you to easily synchronize Git hooks with a remote repository

issue-mafia is an out-of-the-box CLI that helps you to easily synchronize Git hooks with a remote repository.

Feb 14, 2022
yq lets you read YAML files easily on the terminal. You can find key/values easily
yq lets you read YAML files easily on the terminal. You can find key/values easily

yq yq lets you read YAML files easily on the terminal. You can find key/values easily. Motivation Reading yaml configurations for k8s file becomes ard

Nov 2, 2021