diff options
| author | Jeff Carr <[email protected]> | 2025-08-30 14:42:57 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-08-30 14:42:57 -0500 |
| commit | 7f8f5e3b9b37fccbb357b70e6490823a8b22ae7e (patch) | |
| tree | 11b6f74e8d3f33b3fdb82421cb79653f65685fe8 /add.go | |
| parent | c971bfddf74d48d87f10f5f050b1eef3fd12bf20 (diff) | |
basic JSON parsing into genai struc
Diffstat (limited to 'add.go')
| -rw-r--r-- | add.go | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -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) } |
