Add transcript passthrough processing
This commit is contained in:
29
internal/core/io/files.go
Normal file
29
internal/core/io/files.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package io
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func ReadRequiredFile(path string, label string) ([]byte, error) {
|
||||
contents, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read %s file %q: %w", label, path, err)
|
||||
}
|
||||
return contents, nil
|
||||
}
|
||||
|
||||
func ValidateWellFormedJSON(raw []byte) error {
|
||||
if !json.Valid(raw) {
|
||||
return fmt.Errorf("transcript file is not valid JSON")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func WriteFile(path string, contents []byte) error {
|
||||
if err := os.WriteFile(path, contents, 0o644); err != nil {
|
||||
return fmt.Errorf("failed to write output file %q: %w", path, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user