package maybe
import "github.com/google/renameio/maybe"
Package maybe provides a way to atomically create or replace a file, if technically possible.
Index ¶
Functions ¶
func WriteFile ¶
WriteFile mirrors ioutil.WriteFile. On Linux it uses renameio.WriteFile to create or replace an existing file with the same name atomically. On Windows files cannot be written atomically, so this function falls back to ioutil.WriteFile, which does not write the file atomically and ignores most permission bits. See https://github.com/google/renameio/issues/1 and https://github.com/golang/go/issues/22397#issuecomment-498856679 for discussion.
Prefer using renameio.WriteFile instead so that you get an error if atomic replacement is not possible on the runtime platform. maybe.WriteFile is meant as a convenience wrapper if you are okay with atomic replacement not being supported by the runtime platform.
Source Files ¶
- Version
- v1.0.1 (latest)
- Published
- Apr 6, 2021
- Platform
- js/wasm
- Imports
- 2 packages
- Last checked
- 12 hours ago –
Tools for package owners.