Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/equim-chan/leb128
Go implementation of Little Endian Base 128 codec.
https://github.com/equim-chan/leb128
decoding encoding leb128
Last synced: about 1 month ago
JSON representation
Go implementation of Little Endian Base 128 codec.
- Host: GitHub
- URL: https://github.com/equim-chan/leb128
- Owner: Equim-chan
- License: bsd-3-clause
- Created: 2017-12-15T18:21:41.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-26T18:06:23.000Z (over 5 years ago)
- Last Synced: 2024-06-21T06:12:17.009Z (6 months ago)
- Topics: decoding, encoding, leb128
- Language: Go
- Size: 14.6 KB
- Stars: 8
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# leb128
[![Travis](https://img.shields.io/travis/Equim-chan/leb128.svg)](https://travis-ci.org/Equim-chan/leb128)
[![Coverage Status](https://img.shields.io/codecov/c/gh/Equim-chan/leb128.svg)](https://codecov.io/gh/Equim-chan/leb128)
[![Release](https://img.shields.io/github/release/Equim-chan/leb128.svg)](https://github.com/Equim-chan/leb128/releases/latest)
[![Go Report Card](https://goreportcard.com/badge/github.com/Equim-chan/leb128)](https://goreportcard.com/report/github.com/Equim-chan/leb128)
[![License](https://img.shields.io/badge/BSD-3-blue.svg)](https://github.com/Equim-chan/leb128/blob/master/LICENSE)
[![GoDoc](http://img.shields.io/badge/godoc-reference-5272B4.svg)](https://godoc.org/ekyu.moe/leb128)Go implementation of [Little Endian Base 128 codec](https://en.wikipedia.org/wiki/LEB128).
## Install
```bash
$ go get -u ekyu.moe/leb128
# or better
$ dep ensure -add ekyu.moe/leb128
```## Example
```go
package mainimport (
"fmt""ekyu.moe/leb128"
)func main() {
// Notes: These specs are taken from https://en.wikipedia.org/wiki/LEB128
// Encode unsigned LEB128
fmt.Printf("%x\n", leb128.AppendUleb128(nil, 624485)) //=> e58e26// Encode signed LEB128
fmt.Printf("%x\n", leb128.AppendSleb128(nil, -624485)) //=> 9bf159// Decode unsigned LEB128, n is the number of bytes read
u, n := leb128.DecodeUleb128([]byte{0xe5, 0x8e, 0x26, 'a', 'b', 'c'})
fmt.Printf("%d %d\n", u, n) //=> 624485 3// Decode signed LEB128, n is the number of bytes read
s, n := leb128.DecodeSleb128([]byte{0x9b, 0xf1, 0x59, 'd', 'e', 'f'})
fmt.Printf("%d %d\n", s, n) //=> -624485 3
}
```## LICENSE
[BSD-3-clause](https://github.com/Equim-chan/leb128/blob/master/LICENSE)Notes: The encode part is an edited fork of [/src/cmd/internal/dwarf/dwarf.go](https://golang.org/src/cmd/internal/dwarf/dwarf.go) licensed under [a BSD-style license](https://golang.org/LICENSE).