Fix marshaler detection

Here's a reproducible case:

```
type T []byte

func (x T) MarshalBencode() ([]byte, error) {
	fmt.Println("THIS GOT CALLED")
	return []byte("x"), nil
}

encoded, err := bencode.EncodeBytes([]interface{}{
	T("something"),
})
fmt.Println(encoded)
```

Notice that MarshalBencode() is not called when it should be.

The problem stems from NumMethod() returning 0 for the interface, even though the `vi.(Marshaler)` cast would succeed. Removing that if check fixed the issue for me.
2 files changed
tree: 1975880ad5a9edc30571eafaee94f2f98965fb63
  1. .gitignore
  2. .travis.yml
  3. AUTHORS
  4. LICENSE
  5. README.md
  6. decode.go
  7. decode_test.go
  8. doc.go
  9. encode.go
  10. encode_decode_test.go
  11. encode_test.go
  12. example_test.go
  13. raw.go
  14. tag.go
  15. tracer.go
README.md

bencode

GoDoc Build Status Sourcegraph

Bencode is a library for encoding/decoding bencoded data into Go data structures. The api is designed to be similar to the JSON api in the Go standard library.

Documentation

Documentation at http://godoc.org/github.com/zeebo/bencode