From 4fd6fd81d352cdec499616485879b1ac48b6f198 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 22 Aug 2025 00:50:31 -0500 Subject: attempts to debug Marshal() errors --- helpers.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'helpers.go') diff --git a/helpers.go b/helpers.go index 7841e87..5b42533 100644 --- a/helpers.go +++ b/helpers.go @@ -19,7 +19,7 @@ func (c *Chats) AddGeminiComment(s string) *Chat { chat.Content = s chat.Ctime = timestamppb.New(time.Now()) - c.Append(chat) + c.AppendNew(chat) return chat } @@ -30,7 +30,7 @@ func (c *Chats) AddUserComment(s string) *Chat { chat.From = Who_USER chat.Content = s - c.Append(chat) + c.AppendNew(chat) return chat } @@ -83,7 +83,7 @@ func (all *Chats) AddFile(filename string) error { } newc.Content = content newc.VerifyUuid() - all.AppendByUuid(newc) + all.AppendNew(newc) } return nil @@ -110,3 +110,13 @@ func (c *Chat) VerifyUuid() bool { } return false } + +func (x *Chats) AppendNew(y *Chat) { + x.Lock() + defer x.Unlock() + + var chat *Chat + chat = proto.Clone(y).(*Chat) + + x.Chats = append(x.Chats, chat) +} -- cgit v1.2.3