From 7f8f5e3b9b37fccbb357b70e6490823a8b22ae7e Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 30 Aug 2025 14:42:57 -0500 Subject: basic JSON parsing into genai struc --- add.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'add.go') diff --git a/add.go b/add.go index 88d4ceb..01ff836 100644 --- a/add.go +++ b/add.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "os" "path/filepath" @@ -14,15 +13,15 @@ import ( func addFile(filename string) (*chatpb.Chats, error) { data, err := os.ReadFile(filename) if err != nil { - return nil, fmt.Errorf("failed to read file %s: %w", filename, err) + return nil, log.Errorf("failed to read file %s: %w", filename, err) } logData, err := chatpb.UnmarshalChatsTEXT(data) if err != nil { - return nil, fmt.Errorf("failed to unmarshal log file %s: %w", filename, err) + return nil, log.Errorf("failed to unmarshal log file %s: %w", filename, err) } - log.Infof("Successfully parsed log file: %s", filename) + log.Info("Successfully parsed log file: %s", filename) // Get the directory of the log file to resolve relative content paths. logDir := filepath.Dir(filename) @@ -35,7 +34,7 @@ func addFile(filename string) (*chatpb.Chats, error) { contentPath := filepath.Join(logDir, contentFile) contentBytes, err := os.ReadFile(contentPath) if err != nil { - entry.Content = fmt.Sprintf("--- ERROR: Could not read content file %s: %v ---", contentPath, err) + entry.Content = log.Sprintf("--- ERROR: Could not read content file %s: %v ---", contentPath, err) } else { entry.Content = string(contentBytes) } @@ -48,7 +47,7 @@ func addFile(filename string) (*chatpb.Chats, error) { snippetPath := filepath.Join(logDir, snippetFile) contentBytes, err := os.ReadFile(snippetPath) if err != nil { - snippet.Content = fmt.Sprintf("--- ERROR: Could not read snippet file %s: %v ---", snippetPath, err) + snippet.Content = log.Sprintf("--- ERROR: Could not read snippet file %s: %v ---", snippetPath, err) } else { snippet.Content = string(contentBytes) } -- cgit v1.2.3