fsext

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2025 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package fsext provides filesystem extensions for working with embedded files.

It includes utilities for copying files from embed.FS to the OS filesystem and reading embedded content.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyAllEmbed

func CopyAllEmbed(efs embed.FS, destDir string) error

CopyAllEmbed copies everything from the root of the embedded FS to destDir.

func CopyFromEmbed

func CopyFromEmbed(fsx fs.FS, srcDir, destDir string) error

CopyFromEmbed recursively copies all files from an embed.FS directory to a destination.

func DirExists added in v0.1.0

func DirExists(fs afero.Fs, path string) bool

DirExists checks if a directory exists, ignoring any errors.

Returns true if the directory exists, false otherwise.

func EnsureDir added in v0.1.0

func EnsureDir(fs afero.Fs, filePath string) error

EnsureDir ensures the parent directory of the given file path exists.

Returns an error if the directory cannot be created.

func Exists added in v0.1.0

func Exists(fs afero.Fs, path string) bool

Exists checks if a path exists, ignoring any errors.

Returns true if the path exists, false otherwise.

func MustReadFromEmbed added in v0.0.8

func MustReadFromEmbed(fs embed.FS, name string) string

MustReadFromEmbed reads a file from an embedded filesystem and returns its contents as a string.

Panics if the file cannot be read.

func ReadFromEmbed added in v0.0.8

func ReadFromEmbed(fs embed.FS, name string) (string, error)

ReadFromEmbed reads a file from an embedded filesystem and returns its contents as a string.

Returns an error if the file cannot be read.

Types

type FS

type FS interface {
	afero.Fs
}

FS is a stub for afero.Fs for testing.

Jump to

Keyboard shortcuts

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