code: func RenameFileCopyPermissions(srcfile, destfile string) error {
  	info, err := os.Stat(destfile)
  	if os.IsNotExist(err) {
  		// no original file
  	} else if err != nil {
  		return err
  	} else {
  		if err := os.Chmod(srcfile, info.Mode()); err != nil {
  			return fmt.Errorf("can't set filemode on file %q: %v", srcfile, err)
  		}
  	}
  
  	if err := os.Rename(srcfile, destfile); err != nil {
  		return fmt.Errorf("cannot replace %q with %q: %v", destfile, srcfile, err)
  	}
  	return nil
  }
docs: // RenameFileCopyPermissions moves srcfile to destfile, replacing destfile if
  // necessary and also copying the permissions of destfile if it already exists