Files
kontor/kontor-gin/internal/api/file.go
T
Thomas Peetz 72c08f9731
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
Gitea Actions Demo / build-and-test (push) Failing after 29m54s
add method to handlers
2026-10-26 22:41:15 +01:00

23 lines
450 B
Go

package api
import (
"encoding/json"
"log/slog"
"os"
)
func WriteJson(data *ExportData, fileName string) error {
jsonData, err := json.MarshalIndent(data, "", " ")
if err != nil {
slog.Info("JSON MarshalIndent failed", "Error:", err)
return err
}
// Write bytes to file
err = os.WriteFile(fileName, jsonData, 0644)
if err != nil {
slog.Info("Error writing file:", "Error", err)
return err
}
return nil
}