func Copy(source, dest string) (err error) {
	// Don't backup files of backup.
	if dest[len(dest)-1] != '~' {
		if err = Backup(dest); err != nil {
			return
		}
	}

	srcFile, err := os.Open(source)
	if err != nil {
		return err
	}
	defer func() {
		err2 := srcFile.Close()
		if err2 != nil && err == nil {
			err = err2
		}
	}()

	srcInfo, err := os.Stat(source)
	if err != nil {
		return err
	}

	dstFile, err := os.OpenFile(dest, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, srcInfo.Mode().Perm())
	if err != nil {
		return err
	}

	_, err = io.Copy(dstFile, srcFile)
	err2 := dstFile.Close()
	if err2 != nil && err == nil {
		err = err2
	}
	return
}
func Copy(source, dest string) (err error) {
	
	if dest[len(dest)-1] != '~' {
		if err = Backup(dest); err != nil {
			return
		}
	}

	srcFile, err := os.Open(source)
	if err != nil {
		return err
	}
	defer func() {
		err2 := srcFile.Close()
		if err2 != nil && err == nil {
			err = err2
		}
	}()

	srcInfo, err := os.Stat(source)
	if err != nil {
		return err
	}

	dstFile, err := os.OpenFile(dest, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, srcInfo.Mode().Perm())
	if err != nil {
		return err
	}

	_, err = io.Copy(dstFile, srcFile)
	err2 := dstFile.Close()
	if err2 != nil && err == nil {
		err = err2
	}
	return
}
func Copy ( source , dest string ) ( err error ) { // Don't backup files of backup. if dest [ len ( dest ) - 1 ] != '~' { if err = Backup ( dest ) ; err != nil { return } } srcFile , err := os . Open ( source ) if err != nil { return err } defer func ( ) { err2 := srcFile . Close ( ) if err2 != nil && err == nil { err = err2 } } ( ) srcInfo , err := os . Stat ( source ) if err != nil { return err } dstFile , err := os . OpenFile ( dest , os . O_WRONLY | os . O_CREATE | os . O_TRUNC , srcInfo . Mode ( ) . Perm ( ) ) if err != nil { return err } _ , err = io . Copy ( dstFile , srcFile ) err2 := dstFile . Close ( ) if err2 != nil && err == nil { err = err2 } return }
// Copy copies file in source to file in dest preserving the mode attributes.
Copy copies file in source to file in dest preserving the mode attributes .