From 4775ebb83c2f4d3595ba736e3d7e20f731e8c9e9 Mon Sep 17 00:00:00 2001 From: Bas Westerbaan Date: Wed, 10 Jul 2024 13:16:12 +0200 Subject: [PATCH] Add some documentation --- README.md | 17 +++++++++++++++++ lib.go | 4 ++++ 2 files changed, 21 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..31aa69c --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +go-and +====== + +Fast bitwise and for `[]byte` slices. + +```go +import "github.com/bwesterb/go-and" + +func main() { + var a, b, dst []byte + + // ... + + // Sets dst to the bitwise and of a and b + and.And(dst, a, b) +} +``` diff --git a/lib.go b/lib.go index 61456fc..1b608fd 100644 --- a/lib.go +++ b/lib.go @@ -1,9 +1,13 @@ +// and implements bitwise and for two byte-slices. package and import ( "encoding/binary" ) +// Writes bitwise and of a and b to dst. +// +// Panics if len(a) ≠ len(b), or len(dst) ≠ len(a). func And(dst, a, b []byte) { if len(a) != len(b) || len(b) != len(dst) { panic("lengths of a, b and dst must be equal")