mirror of
https://github.com/anotherhadi/github-recon.git
synced 2026-10-05 10:58:25 +02:00
Init v2, rewrite
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
|
||||
github_recon_settings "github.com/anotherhadi/github-recon/settings"
|
||||
)
|
||||
|
||||
func writeJson(s github_recon_settings.Settings, data any) {
|
||||
if s.JsonOutput == "" {
|
||||
return
|
||||
}
|
||||
file, err := os.Create(s.JsonOutput)
|
||||
if err != nil {
|
||||
s.Logger.Error("Failed to create JSON file", "err", err)
|
||||
return
|
||||
}
|
||||
|
||||
defer func() {
|
||||
_ = file.Close()
|
||||
}()
|
||||
|
||||
as_json, _ := json.MarshalIndent(data, "", "\t")
|
||||
_, err = file.Write(as_json)
|
||||
if err != nil {
|
||||
s.Logger.Error("Failed to write to JSON file", "err", err)
|
||||
return
|
||||
}
|
||||
s.Logger.Info("JSON output written to file", "file", s.JsonOutput)
|
||||
}
|
||||
Reference in New Issue
Block a user