fsutil

package
v0.0.0-...-94dd193 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 10 Imported by: 7

Documentation

Overview

Package fsutil provides filesystem-related functions.

Index

Constants

View Source
const (
	// DirMode is the default permission used when creating directories
	DirMode = 0755
	// FileMode is the default permission used when creating files
	FileMode = 0644
)

Variables

This section is empty.

Functions

func CommonFileMode

func CommonFileMode(fi fs.FileInfo) fs.FileMode

CommonFileMode is a function that returns the common file permissions: 0644 for all files, and 0755 for all directories. It is provided as a helper for CopyFSToDisk's common use case

func CopyDir

func CopyDir(src, dest string) error

CopyDir is a utility to assist with copying a directory from src to dest. Note that directory permissions are not maintained, but the permissions of the files in those directories are.

func CopyFSToDisk

func CopyFSToDisk(src fs.FS, destDir string, modeSetter func(fs.FileInfo) os.FileMode) error

CopyFSToDisk copies an embedded FS to a given directory. Because go's embed does not preserve the file mode, you must also pass a function that will return the desired file mode for each file.

func CopyFile

func CopyFile(src, dest string) error

CopyFile is a utility to assist with copying a file from src to dest. Note that file permissions are maintained.

func Gopath

func Gopath() string

Gopath will return the current GOPATH as set by environment variables and will fall back to ~/go if a GOPATH is not set.

func UntarBundle

func UntarBundle(destination string, source string) error

UntarBundle will untar a source tar.gz archive to the supplied destination. Note that this calls `filepath.Dir(destination)`, which has the effect of stripping the last component from destination.

Types

This section is empty.

Jump to

Keyboard shortcuts

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