Skip to content

A tiny torrent magnet file Bencode encoding/decoding package.

License

Notifications You must be signed in to change notification settings

tekintian/bencode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tiny Bencode encoding/decoding package.

Uses similar API design to Go's json package. tiny from https://github.com/anacrolix/torrent

Install

go get github.com/tekintian/bencode

Usage

package demo

import (
	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)
}

About

A tiny torrent magnet file Bencode encoding/decoding package.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages