fsx

package module
v0.0.0-...-c4d1857 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

README

logo

fsx

License Go Reference Go Report Card GitHub CI codecov

Clean, simple filesystem abstraction for Go 🗃️

[!WARNING] fsx is in early development and is not yet ready for use

caution

Project Description

fsx is a minimal, simple filesystem abstraction for Go, allowing you to interact with a filesystem in a completely agnostic way whether it's the real OS filesystem, an in-memory filesystem for testing, or anything else!

It's inspired by projects like spf13/afero, C2FO/vfs and go-git/go-billy.

So why another one?

Good question!

  1. The alternatives don't quite do what I want (although go-git/go-billy is the closest)
  2. They have additional features and functionality I don't need or want (like S3 support, fully qualified URIs etc.) or APIs that I don't think are optimal
  3. I like building things 🤷🏻‍♂️ it's the best way to really understand how something works

Installation

go get github.com/FollowTheProcess/fsx@latest

Quickstart

Credits

This package was created with copier and the FollowTheProcess/go_copier project template.

Documentation

Overview

Package fsx provides a clean, simple filesystem abstraction allowing you to use a consistent API regardless of the underlying implementation whether it's the real OS filesystem or a memory backed test filesystem.

Index

Constants

View Source
const (
	// DefaultDirPermissions are the default UNIX permission bits for a new directory, they
	// are the equivalent permissions to the result of running mkdir.
	DefaultDirPermissions = 0o755

	// DefaultFilePermissions are the default UNIX permission bits for a new file, they
	// are the equivalent permissions to the result of running touch.
	DefaultFilePermissions = 0o666

	// Separator is the OS-specific filepath separator.
	Separator = string(filepath.Separator)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File interface {

	// Name returns the name of the file as presented to Open.
	//
	// It is safe to call Name after Close.
	Name() string

	// Exists reports whether the file exists in the filesystem.
	Exists() bool

	// Truncate truncates the file to a specific size.
	Truncate(size int64) error
}

File represents a single named file in the filesystem.

type FileSystem

type FileSystem interface {
	// Create creates a new named file (truncating it if it already exists).
	Create(name string) (File, error)
}

FileSystem represents an abstract filesystem in a storage-agnostic interface.

Directories

Path Synopsis
internal
flag
Package flag provides constants for OS file/dir flags.
Package flag provides constants for OS file/dir flags.
Package memory provides a FileSystem implementation backed by a in-memory storage mechanism that does not require any access to the underlying OS.
Package memory provides a FileSystem implementation backed by a in-memory storage mechanism that does not require any access to the underlying OS.
Package real provides a FileSystem implementation backed by the OS for interacting with the real, physical file system in an OS agnostic way.
Package real provides a FileSystem implementation backed by the OS for interacting with the real, physical file system in an OS agnostic way.

Jump to

Keyboard shortcuts

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