Help us shape the future of Go! Take the 2026 Go Developer Survey

fileperm

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package fileperm restricts a file to the account that wrote it: mode 0600 on Unix, an explicit access list on Windows, where a mode only sets the read-only attribute and protects nothing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Describe

func Describe() string

Describe says what the restriction achieves here, for the warning that quotes it. On Unix a mode is the whole story.

func RestrictToOwner

func RestrictToOwner(path string) error

RestrictToOwner reasserts owner-only permissions after the file is in place. The write already asked for 0600; this catches a file an earlier version, a umask or a restore left wider.

func WriteFile

func WriteFile(path string, data []byte) error

WriteFile replaces path with data as one step and restricts it to the current account.

The data goes to a temporary file in the same directory first and is renamed over path, so a reader in another process sees the old file or the new one, never half of either. The temporary name is unique, because two processes can save at once. The restriction comes after the rename: on Windows the access list belongs to the file at its final path, and a temporary file's list does not survive the move.

Types

This section is empty.

Jump to

Keyboard shortcuts

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