Beispiel #1
0
func writeJson(filename string, x interface{}) error {
	data, err := json.MarshalIndent(x, "  ", "  ")
	if err != nil {
		return err
	}
	return ioutil2.WriteFileAtomic(filename, data, 0660)
}
Beispiel #2
0
// Atomically write a marshaled structure to disk.
func WriteJson(filename string, val interface{}) error {
	data, err := json.MarshalIndent(val, "  ", "  ")
	if err != nil {
		return fmt.Errorf("WriteJson failed: %v %v", filename, err)
	}
	return ioutil2.WriteFileAtomic(filename, data, 0660)
}