The highest tagged major version is
v2.
module
Version:
v0.1.0
Opens a new window with list of versions in this module.
Published: Jun 5, 2019
License: Apache-2.0
Opens a new window with license information.
README
¶
go-bit
A library to read/write bits from a byte slice.
Installation
$ go get github.com/nokute78/go-bit/pkg/bit
Usage
package main
import (
"fmt"
"github.com/nokute78/go-bit/pkg/bit"
)
func main() {
b := []byte{0x78} /* 0111_1000 in bit */
/* try to get 4bits(1111b) from 0111_1000 */
off := bit.Offset{Byte: 0, Bit: 3}
ret, err := bit.GetBits(b, off, 4)
if err != nil {
fmt.Printf("error:%s\n", err)
}
fmt.Printf("0x%x\n", ret) /* Print 0x0f = 1111b */
}
License
Apache License v2.0
Click to show internal directories.
Click to hide internal directories.