From d672a80ab485545f67a769969b65a2d317fbe071 Mon Sep 17 00:00:00 2001 From: HeBeCoding Date: Thu, 8 Jun 2023 22:07:45 -0400 Subject: [PATCH] testing new XID method --- utils/xid.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/utils/xid.go b/utils/xid.go index 1636e20..673514e 100644 --- a/utils/xid.go +++ b/utils/xid.go @@ -1,8 +1,9 @@ package utils import ( + "encoding/json" + "github.com/rs/xid" - "go.mongodb.org/mongo-driver/bson" ) type XID string @@ -15,15 +16,13 @@ func (id *XID) String() string { } func (id XID) MarshalBSON() ([]byte, error) { - return bson.Marshal(struct { - ID string - }{string(id)}) + return json.Marshal(&id) } func (id *XID) UnmarshalBSON(data []byte) error { var tmp struct{ ID string } - if err := bson.Unmarshal(data, &tmp); err != nil { + if err := json.Unmarshal(data, &tmp); err != nil { return err }