summaryrefslogtreecommitdiff
path: root/core/core.go
diff options
context:
space:
mode:
authornytpu <alex@nytpu.com>2021-03-18 11:08:23 -0600
committernytpu <alex@nytpu.com>2021-03-18 11:08:23 -0600
commit853993cdd6f874896d2982401a695cb82e2e6ecc (patch)
tree9453753bf93e070ae93035871e711b1a0717ccd9 /core/core.go
parentcace315effed4d3f85b89d83ac4b10f72a6af8f1 (diff)
add method to write structs to disk
Diffstat (limited to 'core/core.go')
-rw-r--r--core/core.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/core.go b/core/core.go
index 70f9cb7..1f92d76 100644
--- a/core/core.go
+++ b/core/core.go
@@ -62,3 +62,18 @@ func Init(dataPath string) error {
}
return nil
}
+
+func (d *FullData) WriteJSON(dataPath string) error {
+ d.Lock()
+ jsonBytes, err := json.MarshalIndent(&d, "", "\t")
+ d.Unlock()
+ if err != nil {
+ return err
+ }
+ err = ioutil.WriteFile(filepath.Join(dataPath, "comitium.json"), jsonBytes, 0666)
+ if err != nil {
+ return err
+ }
+
+ return nil
+}