// WriteExistingFile writes the byte array to an existing file.
WriteExistingFile writes the byte array to an existing file.
// WriteExistingFile writes the byte array to an existing file .
func WriteExistingFile(
	fileName string,
	data []byte,
) error {
	f, err := os.OpenFile(fileName, os.O_WRONLY|os.O_TRUNC, 0)
	if err != nil {
		return err
	}
	n, err := f.Write(data)
	if err == nil && n < len(data) {
		err = io.ErrShortWrite
	}
	if err1 := f.Close(); err == nil {
		err = err1
	}
	return err
}
func WriteExistingFile ( fileName string , data [ ] byte , ) error { f , err := os . OpenFile ( fileName , os . O_WRONLY | os . O_TRUNC , 0 ) if err != nil { return err } n , err := f . Write ( data ) if err == nil && n < len ( data ) { err = io . ErrShortWrite } if err1 := f . Close ( ) ; err == nil { err = err1 } return err }
WriteExistingFile writes the byte array to an existing file.
WriteExistingFile writes the byte array to an existing file .