utilio

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFileTooLarge = errors.New("file exceeds maximum allowed size")

Functions

func DecompressTarGzFromRemote

func DecompressTarGzFromRemote(ctx context.Context, url string) iter.Seq2[*TarFile, error]

DecompressTarGzFromRemote returns an iterator that yields the files contained in a .tar.gz file located at the given URL.

func DownloadToLocalFile

func DownloadToLocalFile(ctx context.Context, url string, filename string, perm os.FileMode) error

DownloadToLocalFile downloads content from giving URL to local file and sets the specified permissions. It limits the size of the content to 1 GiB and returns an error if the limit is exceeded. It ensures that the target directory exists and handles the file writing atomically.

NOTE: we assume the filename is trusted and cleaned without path traversal characters.

func InstallFile

func InstallFile(filename string, r io.Reader, perm os.FileMode) error

InstallFile writes the content from the provided reader to a local file with specified permissions. It limits the size of the content to 1 GiB and returns an error if the limit is exceeded. It ensures that the target directory exists and handles the file writing atomically.

NOTE: we assume the filename is trusted and cleaned without path traversal characters.

func InstallFileWithLimitedSize

func InstallFileWithLimitedSize(filename string, r io.Reader, perm os.FileMode, maxBytes int64) error

InstallFileWithLimitedSize streams content to local file with limited size and specified permissions. It ensures that the target directory exists and handles the file writing atomically.

NOTE: we assume the filename is trusted and cleaned without path traversal characters.

func IsExecutable

func IsExecutable(filePath string) bool

func WriteFile

func WriteFile(filename string, content []byte, perm os.FileMode) error

WriteFile writes the provided content to a local file with specified permissions. It ensures that the target directory exists and handles the file writing atomically.

NOTE: we assume the filename is trusted and cleaned without path traversal characters.

Types

type TarFile

type TarFile struct {
	Name string
	Body io.Reader
}

Jump to

Keyboard shortcuts

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