From 0f4b7ad08e5fdda2ca569aaeba9b9bebd06f9767 Mon Sep 17 00:00:00 2001 From: Matthias Fulz Date: Thu, 21 Oct 2021 11:54:42 +0200 Subject: [PATCH] Moved RegisterType to marshalVal --- encoder.go | 8 -------- marshal.go | 4 ++++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/encoder.go b/encoder.go index 9e8ea63..b348f61 100644 --- a/encoder.go +++ b/encoder.go @@ -4,8 +4,6 @@ import ( "fmt" "io" "sync" - - "gitea.olznet.de/OlzNet/slog" ) type Encoder struct { @@ -24,12 +22,6 @@ func (enc *Encoder) Encode(e interface{}) (err error) { if err != nil { 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 if b, err = marshalVal(v.Interface()); err != nil { diff --git a/marshal.go b/marshal.go index 6ba93a6..294dcfc 100644 --- a/marshal.go +++ b/marshal.go @@ -371,6 +371,10 @@ func marshalType(e interface{}, ntype *NType) (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) if err != nil { return ret, ErrValueInvalid