fsutil

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 12 Imported by: 3 modules, 20 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 fsutil contains utilities for working with the file system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteCountIEC deprecated

func ByteCountIEC[T ~int64 | ~uint64 | ~int | ~uint | ~int32 | ~uint32 | ~int16 | ~uint16 | ~int8 | ~uint8 | ~uintptr](
	count T) string

ByteCountIEC converts a byte count to string using the appropriate unit (B, Kb, MiB, GiB, ...). It uses the binary prefix system from IEC -- so powers of 1024 (as opposed to powers 1000).

Deprecated: use humanize.Bytes() instead.

func FileExists

func FileExists(path string) (bool, error)

FileExists returns whether the file or directory exists or an error if something went wrong in the filesystem.

func MustFileExists

func MustFileExists(path string) bool

MustFileExists returns whether the file or directory exists. It panics on file system errors.

func MustReplaceTildeInDir

func MustReplaceTildeInDir(dir string) string

MustReplaceTildeInDir by the user's home directory. Returns dir if it doesn't start with "~".

It may panic with an error if `dir` has an unknown user (e.g: `~unknown/...`)

func ReplaceTildeInDir

func ReplaceTildeInDir(dir string) (string, error)

ReplaceTildeInDir by the user's home directory. Returns dir if it doesn't start with "~".

It returns an error if `dir` has an unknown user or some other filesystem error (e.g: `~unknown/...`)

func ReportedClose

func ReportedClose(closer io.Closer, name string, reportErrPtr *error)

ReportedClose closes the closer object (a file?) and reports in case of error.

It reports by setting reportErrPtr if it's set and not in use yet. Otherwise, it logs the error and continues.

Use this in a defer statement.

func ValidateChecksum

func ValidateChecksum(path, checkHash string) error

ValidateChecksum verifies that the checksum of the file in the given path matches the checksum given. If it fails, it will remove the file (!) and return and error. If checkHash is empty, this is a no-op.

Types

This section is empty.

Jump to

Keyboard shortcuts

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