A simple library for parse and unmarshall the bencode format with some utilities.
go get -u github.com/trixky/gobencode
import bencode "github.com/trixky/gobencode"
bc, err := gobencode.UnmarshallFromReader(reader)
data, err := gobencode.ParseFromReader(reader)
if err != nil {
return err
}
bc := gobencode.bencode.Bencode{
Data: data
}
if err := bc.UnmarshallAnnounce(); err != nil {
return err
}
if err := bc.UnmarshallAnnounceList(); err != nil {
return err
}
if err := bc.RandomizeAnnounceList(); err != nil {
return err
}
if err := bc.UnmarshallInfo(); err != nil {
return err
}
if err := bc.GetInfoHash(); err != nil {
return err
}