https://github.com/tekintian/bencode
A tiny torrent magnet file Bencode encoding/decoding package.
https://github.com/tekintian/bencode
bencode bencode-parser go golang golang-library magnet torrent
Last synced: about 1 month ago
JSON representation
A tiny torrent magnet file Bencode encoding/decoding package.
- Host: GitHub
- URL: https://github.com/tekintian/bencode
- Owner: tekintian
- License: other
- Created: 2022-06-26T08:49:51.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-28T01:28:57.000Z (almost 3 years ago)
- Last Synced: 2025-02-15T05:28:33.533Z (3 months ago)
- Topics: bencode, bencode-parser, go, golang, golang-library, magnet, torrent
- Language: Go
- Homepage:
- Size: 13.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tiny Bencode encoding/decoding package.
Uses similar API design to Go's json package.
tiny from https://github.com/anacrolix/torrent## Install
```sh
go get github.com/tekintian/bencode
```## Usage
```go
package demoimport (
bencode "github.com/tekintian/bencode"
)type Message struct {
Query string `json:"q,omitempty" bencode:"q,omitempty"`
}var v Message
func main(){
// encode
data, err := bencode.Marshal(v)
if err != nil {
log.Fatal(err)
}//decode
err := bencode.Unmarshal(data, &v)
if err != nil {
log.Fatal(err)
}
fmt.Println(v)
}
```