utilities

package
v2.6.0-beta5 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package utilities provides helper functions for CLI input validation and error handling.

Index

Constants

View Source
const DefaultAssetsDirName = "images"

DefaultAssetsDirName is the assets directory used, relative to the posts directory, when no --assets-dir flag is given.

Variables

This section is empty.

Functions

func CliErrorHandler

func CliErrorHandler(err error)

CliErrorHandler handles errors by printing them to stdout or stderr and exits if fatal.

func GetDirectoryFromInput

func GetDirectoryFromInput(path string, nonexistentAllowed bool) (string, error)

GetDirectoryFromInput validates a path and returns it as an fs.FS.

func OpenAssetsDir added in v2.6.0

func OpenAssetsDir(assetsDir, postsDir string) (*os.Root, error)

OpenAssetsDir opens the assets directory as an os.Root, so files served or copied from it cannot escape the directory via ".." or symbolic links.

When assetsDir is empty it defaults to <postsDir>/images. If the resolved directory does not exist, OpenAssetsDir returns a nil Root and nil error: asset support is silently off. Any other failure, such as the path not being a directory, is returned as an error.

The caller must Close a non-nil Root.

Types

This section is empty.

Jump to

Keyboard shortcuts

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