|
|
2 giorni fa | |
|---|---|---|
| .. | ||
| README.md | 2 giorni fa | |
| api.go | 2 giorni fa | |
| bytes.go | 2 giorni fa | |
| decode.go | 2 giorni fa | |
| encode.go | 2 giorni fa | |
| misc.go | 2 giorni fa | |
| scanner.go | 2 giorni fa | |
| string.go | 2 giorni fa | |
| string_go120.go | 2 giorni fa | |
| tags.go | 2 giorni fa | |
Bencode encoding/decoding sub package. Uses similar API design to Go's json package.
go get github.com/anacrolix/torrent
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)
}