Moved RegisterType to marshalVal

This commit is contained in:
Matthias Fulz 2021-10-21 11:54:42 +02:00
parent 35eae62602
commit 0f4b7ad08e
2 changed files with 4 additions and 8 deletions

View File

@ -4,8 +4,6 @@ import (
"fmt" "fmt"
"io" "io"
"sync" "sync"
"gitea.olznet.de/OlzNet/slog"
) )
type Encoder struct { type Encoder struct {
@ -24,12 +22,6 @@ func (enc *Encoder) Encode(e interface{}) (err error) {
if err != nil { if err != nil {
return err return err
} }
if err = RegisterType(v.Interface()); err != nil {
return err
}
for _, t := range cacheTypes.ntypes {
slog.LOG_DEBUGFLN("t: %v", t)
}
var b []byte var b []byte
if b, err = marshalVal(v.Interface()); err != nil { if b, err = marshalVal(v.Interface()); err != nil {

View File

@ -371,6 +371,10 @@ func marshalType(e interface{}, ntype *NType) (ret []byte, err error) {
} }
func marshalVal(e interface{}) (ret []byte, err error) { func marshalVal(e interface{}) (ret []byte, err error) {
if err = RegisterType(e); err != nil {
return ret, err
}
i, n, nl, err := indirectType(e) i, n, nl, err := indirectType(e)
if err != nil { if err != nil {
return ret, ErrValueInvalid return ret, ErrValueInvalid