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

fsutil

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package fsutil holds small filesystem helpers that refuse to follow symlinks. App directories can contain files that did not come from SimpleDeploy (git sync pulls, container bind mounts), so reads and writes of managed files (docker-compose.yml, .env, sidecars) must never be redirected to a path outside the app directory.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotRegular = errors.New("not a regular file")

ErrNotRegular is returned when a path is a symlink, directory, device or any other non-regular file.

Functions

func EnsureNoSymlinks(root, target string) error

EnsureNoSymlinks verifies that every existing path component of target below root (including target itself) is not a symlink. Components that do not exist yet are allowed. target must be inside root.

func OpenRegularFile

func OpenRegularFile(path string) (*os.File, error)

OpenRegularFile opens path read-only, refusing symlinks and non-regular files. Callers must close the returned file.

func ReadRegularFile

func ReadRegularFile(path string) ([]byte, error)

ReadRegularFile reads path, refusing symlinks and non-regular files.

func WriteFileAtomic

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

WriteFileAtomic writes data to a temp file in the same directory and renames it over path. Rename replaces a symlink at path instead of following it, so the write can never land outside the directory.

Types

This section is empty.

Jump to

Keyboard shortcuts

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