aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bencode/bencode.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/bencode/bencode.go b/bencode/bencode.go
index d2d7815..f8e72ec 100644
--- a/bencode/bencode.go
+++ b/bencode/bencode.go
@@ -109,13 +109,17 @@ func marshalInt(out io.Writer, i int64) {
fmt.Fprintf(out, "i%de", i)
}
-func Unmarshal(data []byte, v interface{}) error {
- return nil
-}
-
func parseTag(tag string) (string, string) {
if i := strings.Index(tag, ","); i != -1 {
return tag[:i], tag[i+1:]
}
return tag, ""
}
+
+func Unmarshal(data []byte, v interface{}) error {
+ val := reflect.ValueOf(v)
+ if val.Kind() != reflect.Ptr {
+ return errors.New("non-pointer passed to Unmarshal")
+ }
+ return nil
+}