Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/vendor/github.com/zeebo/bencode/example_test.go
Jeff Becker c088cb2642 add torrent file parsing for upload form
* vendor bencode library github.com/zeebo/bencode

* add metainfo parsing library from XD

* fix up upload handler so to be less cluttered
2017-05-06 07:43:24 -04:00

67 lignes
1 Kio
Go

package bencode
import (
"fmt"
"io"
)
var (
data string
r io.Reader
w io.Writer
)
func ExampleDecodeString() {
var torrent interface{}
if err := DecodeString(data, &torrent); err != nil {
panic(err)
}
}
func ExampleEncodeString() {
var torrent interface{}
data, err := EncodeString(torrent)
if err != nil {
panic(err)
}
fmt.Println(data)
}
func ExampleDecodeBytes() {
var torrent interface{}
if err := DecodeBytes([]byte(data), &torrent); err != nil {
panic(err)
}
}
func ExampleEncodeBytes() {
var torrent interface{}
data, err := EncodeBytes(torrent)
if err != nil {
panic(err)
}
fmt.Println(data)
}
func ExampleEncoder_Encode() {
var x struct {
Foo string
Bar []string `bencode:"name"`
}
enc := NewEncoder(w)
if err := enc.Encode(x); err != nil {
panic(err)
}
}
func ExampleDecoder_Decode() {
dec := NewDecoder(r)
var torrent struct {
Announce string
List [][]string `bencode:"announce-list"`
}
if err := dec.Decode(&torrent); err != nil {
panic(err)
}
}