2
0
mirror of synced 2025-02-24 14:48:27 +00:00
deepsource-autofix[bot] e3d08999e1
Format code with gofumpt (#724)
This commit fixes the style issues introduced in b81470d according to the output
from gofumpt.

Details: https://deepsource.io/gh/anacrolix/torrent/transform/ccafd976-fc9a-4c8a-bbfe-bc36426e79cb/

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2022-02-11 22:45:12 +11:00
..
2021-12-12 16:56:01 +11:00
2021-08-12 13:46:02 +10:00
2016-02-23 21:47:00 +11:00
2022-02-11 22:45:12 +11:00
2021-11-08 14:47:01 +11:00
2017-09-12 18:31:56 +10:00

Bencode encoding/decoding sub package. Uses similar API design to Go's json package.

Install

go get github.com/anacrolix/torrent

Usage

package demo

import (
	bencode "github.com/anacrolix/torrent/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)
}