files

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package files implements generic file tools missing from the standard library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecOnFileLock added in v0.3.5

func ExecOnFileLock(lockPath string, fn func()) (err error)

ExecOnFileLock opens the lockPath file (or creates if it doesn't yet exist), locks it, and executes the function. If the lockPath is already locked, it polls with a 1 to 2 seconds period (randomly), until it acquires the lock.

The lockPath is not removed. It's safe to remove it from the given fn, if one knows that no new calls to ExecOnFileLock with the same lockPath is going to be made.

func Exists

func Exists(filePath string) bool

Exists returns true if file or directory exists.

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 (e.g: `~unknown/...`)

Types

This section is empty.

Jump to

Keyboard shortcuts

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