Documentation
¶
Overview ¶
Package utilities provides helper functions for CLI input validation and error handling.
Index ¶
Constants ¶
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 ¶
GetDirectoryFromInput validates a path and returns it as an fs.FS.
func OpenAssetsDir ¶ added in v2.6.0
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.