Save writes the Database to disk.
()
| 114 | |
| 115 | // Save writes the Database to disk. |
| 116 | func (db *Database) save() error { |
| 117 | // Marshal db.data into JSON |
| 118 | // Write the JSON to the file |
| 119 | f, err := os.Create(db.path) |
| 120 | if err != nil { |
| 121 | return err |
| 122 | } |
| 123 | defer f.Close() |
| 124 | return json.NewEncoder(f).Encode(db.data) |
| 125 | } |