encode

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2022 License: MIT Imports: 1 Imported by: 1

README

Variable-Length Integer Encoding

Variable-Length Integer Encoding Implement

rfc9000

+======+========+=============+=======================+
| 2MSB | Length | Usable Bits | Range                 |
+======+========+=============+=======================+
| 00   | 1      | 6           | 0-63                  |
+------+--------+-------------+-----------------------+
| 01   | 2      | 14          | 0-16383               |
+------+--------+-------------+-----------------------+
| 10   | 4      | 30          | 0-1073741823          |
+------+--------+-------------+-----------------------+
| 11   | 8      | 62          | 0-4611686018427387903 |
+------+--------+-------------+-----------------------+

Install

go get "github.com/adrian-lin-1-0-0/go-variable-length-integer-encoding"

Usage

package main

import (
	"fmt"

	encode "github.com/adrian-lin-1-0-0/go-variable-length-integer-encoding"
)

func main() {
	b, _ := encode.ToVarLenInt(0x3f)
	fmt.Println(encode.ToUint64(b))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToUint64

func ToUint64(b []byte) (uint64, uint8)

func ToVarLenInt

func ToVarLenInt(num uint64) ([]byte, error)

Types

type Error

type Error string

func (Error) Error

func (err Error) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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