diff --git a/atomicfile.go b/atomicfile.go index 60cda2a..ab3f291 100644 --- a/atomicfile.go +++ b/atomicfile.go @@ -7,6 +7,7 @@ import ( "io/ioutil" "os" "path/filepath" + "runtime" ) // File behaves like os.File, but does an atomic rename operation at Close. @@ -34,6 +35,11 @@ func (f *File) Close() error { if err := f.File.Close(); err != nil { return err } + if runtime.GOOS == "windows" { + if err := os.Remove(f.path); err != nil { + return err + } + } if err := os.Rename(f.Name(), f.path); err != nil { return err }