// WriteFile is a safe analog of ioutil.WriteFile.

WriteFile is a safe analog of ioutil.WriteFile.
// WriteFile is a safe analog of ioutil . WriteFile .
func WriteFile(filename string, data []byte, perm os.FileMode) error {
	f, err := Create(filename, perm)
	if err != nil {
		return err
	}
	defer f.Close()
	n, err := f.Write(data)
	if err != nil {
		return err
	}
	if err == nil && n < len(data) {
		err = io.ErrShortWrite
		return err
	}
	return f.Commit()
}
func WriteFile ( filename string , data [ ] byte , perm os . FileMode ) error { f , err := Create ( filename , perm ) if err != nil { return err } defer f . Close ( ) n , err := f . Write ( data ) if err != nil { return err } if err == nil && n < len ( data ) { err = io . ErrShortWrite return err } return f . Commit ( ) }
WriteFile is a safe analog of ioutil.WriteFile.
WriteFile is a safe analog of ioutil . WriteFile .