Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dxtym/beancode
bencode parser
https://github.com/dxtym/beancode
bencode go parser
Last synced: 15 days ago
JSON representation
bencode parser
- Host: GitHub
- URL: https://github.com/dxtym/beancode
- Owner: dxtym
- License: mit
- Created: 2024-06-28T17:29:39.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-07-30T12:28:02.000Z (6 months ago)
- Last Synced: 2024-11-22T14:18:42.592Z (3 months ago)
- Topics: bencode, go, parser
- Language: Go
- Homepage:
- Size: 32.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Beancode
Working with BitTorrent? You need Beancode.
## Features
* Easy API based on stdlib
* Almost full unit test coverage: 86%
* Support int, string, slice, map, and struct## Usage
Let's define a common struct for encoding and decoding processes:
```go
type Boo struct {
Foo int `beancode:"foo"`
Bar string `Beancode:"bar"`
}
```To marshal into Bencode:
```go
from := Boo{Foo: 42, Bar: "qux"}
val, err := beancode.Marshal(from)
```To unmarshal from Bencode:
```go
var to Boo
from := "d3:fooi42e3:bar3:quxe"err := beancode.Unmarshal(from, &to)
```Voila, as simple as that!
## Install
```go
go get github.com/dxtym/beancode
```## Benchmarks
Covered on AMD Ryzen 3 4300U with Radeon Graphics (8GB RAM).
* Marshal: 3652 ns/op, 361 B/op, 17 allocs/op
* Unmarshal: 3672 ns/op, 1515 B/op, 22 allocs/op## Plans
* Implement decode to struct
* Enhance benchmark performance
* Have some documentation## License
[MIT License](LICENSE)