// The info dictionary. See BEP 3 and BEP 52.
type Info struct {
- PieceLength int64 `bencode:"piece length"` // BEP3
- Pieces []byte `bencode:"pieces,omitempty"` // BEP3
- Name string `bencode:"name"` // BEP3
- NameUtf8 string `bencode:"name.utf-8,omitempty"`
- Length int64 `bencode:"length,omitempty"` // BEP3, mutually exclusive with Files
+ PieceLength int64 `bencode:"piece length"` // BEP3
+ // BEP 3. This can be omitted because isn't needed in non-hybrid v2 infos. See BEP 52.
+ Pieces []byte `bencode:"pieces,omitempty"`
+ Name string `bencode:"name"` // BEP3
+ NameUtf8 string `bencode:"name.utf-8,omitempty"`
+ Length int64 `bencode:"length,omitempty"` // BEP3, mutually exclusive with Files
ExtendedFileAttrs
Private *bool `bencode:"private,omitempty"` // BEP27
// TODO: Document this field.
package metainfo
import (
+ g "github.com/anacrolix/generics"
"testing"
"github.com/stretchr/testify/assert"
func TestMarshalInfo(t *testing.T) {
var info Info
+ g.MakeSliceWithLength(&info.Pieces, 0)
b, err := bencode.Marshal(info)
assert.NoError(t, err)
assert.EqualValues(t, "d4:name0:12:piece lengthi0e6:pieces0:e", string(b))