vfs

package
v0.0.0-...-0253919 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: AGPL-3.0 Imports: 3 Imported by: 0

README

vfs

Package vfs provides utilities for managing virtual file systems on contexts to avoid direct calls to the built-in os interface. This is particularly useful for testing. Currently, this wraps the afero virtual file system which provides OS and in memory implementations.

import go.pitz.tech/lib/vfs

Usage

func ToContext
func ToContext(ctx context.Context, fs FS) context.Context

ToContext sets the file system on the provided context.

type FS
type FS = afero.Fs

FS provides a file system abstraction.

func Extract
func Extract(ctx context.Context) FS

Extract pulls the file system from the provided context. If no file system is found, then the defaultFS is returned.

Documentation

Overview

Package vfs provides utilities for managing virtual file systems on contexts to avoid direct calls to the built-in `os` interface. This is particularly useful for testing. Currently, this wraps the afero virtual file system which provides OS and in memory implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToContext

func ToContext(ctx context.Context, fs FS) context.Context

ToContext sets the file system on the provided context.

Types

type FS

type FS = afero.Fs

FS provides a file system abstraction.

func Extract

func Extract(ctx context.Context) FS

Extract pulls the file system from the provided context. If no file system is found, then the defaultFS is returned.

Jump to

Keyboard shortcuts

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