add method to write structs to disk
This commit is contained in:
@@ -62,3 +62,18 @@ func Init(dataPath string) error {
|
|||||||
}
|
}
|
||||||
return nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user