file

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package file writes files atomically, so readers see either the old contents or the new, never a partial write.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(path string, data []byte, perm os.FileMode) error

Write atomically replaces the file at path with data, leaving it with exactly perm whatever the umask and whatever mode an existing file had. It behaves like WriteFunc.

func WriteFunc

func WriteFunc(path string, perm os.FileMode, write func(io.Writer) error) error

WriteFunc atomically replaces the file at path with whatever write writes, leaving it with exactly perm whatever the umask and whatever mode an existing file had.

The content goes to a temporary file in the same directory, which is synced and renamed over path, and then the directory is synced so the rename survives a crash (except on Windows, where directories can't be synced). If write or any step before the rename fails, the temporary file is removed and path is left untouched. If only the directory sync fails, path has already been replaced and the error is still returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL