const arbitraryTimeout … // retry retries ephemeral errors from f up to an arbitrary timeout // to work around filesystem flakiness on Windows and Darwin. func retry(f func() (err error, mayRetry bool)) error { … } // rename is like os.Rename, but retries ephemeral errors. // // On Windows it wraps os.Rename, which (as of 2019-06-04) uses MoveFileEx with // MOVEFILE_REPLACE_EXISTING. // // Windows also provides a different system call, ReplaceFile, // that provides similar semantics, but perhaps preserves more metadata. (The // documentation on the differences between the two is very sparse.) // // Empirical error rates with MoveFileEx are lower under modest concurrency, so // for now we're sticking with what the os package already provides. func rename(oldpath, newpath string) (err error) { … } // readFile is like os.ReadFile, but retries ephemeral errors. func readFile(filename string) ([]byte, error) { … } func removeAll(path string) error { … }