Use one copy of EnforcePtr

This commit is contained in:
Clayton Coleman
2014-10-09 18:38:34 -04:00
parent d488e238dd
commit 13992837ea
3 changed files with 6 additions and 17 deletions

View File

@@ -51,7 +51,7 @@ import (
//
func (s *Scheme) EncodeToVersion(obj interface{}, destVersion string) (data []byte, err error) {
obj = maybeCopy(obj)
v, _ := enforcePtr(obj) // maybeCopy guarantees a pointer
v, _ := EnforcePtr(obj) // maybeCopy guarantees a pointer
if _, registered := s.typeToVersion[v.Type()]; !registered {
return nil, fmt.Errorf("type %v is not registered and it will be impossible to Decode it, therefore Encode will refuse to encode it.", v.Type())
}