gofs

package module
v0.0.0-...-415ec80 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: MIT Imports: 4 Imported by: 1

README

gofs - Abstract File System interface

The gofs package adds Go fs filesystem interface support to any absfs filesystem implementation.

Import

import "github.com/absfs/gofs"

Example Usage

package main

import (
	"fmt"

	"github.com/absfs/gofs"
	"github.com/absfs/memfs"
)

func main() {
	mfs, _ := memfs.NewFS()

	memFile, _ := mfs.Create("foo.txt")
	fmt.Fprintf(memFile, "bar\n")
	memFile.Close()

	var fs gofs.FileSystem
	fs, _ = gofs.NewFs(mfs)

	data, _ := fs.ReadFile("foo.txt")
	fmt.Print(string(data))
	// output: "bar\n"
}

absfs

Check out the absfs repo for more information about the abstract filesystem interface.

LICENSE

This project is governed by the MIT License. See LICENSE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DirEntry

type DirEntry struct {
	FileInfo os.FileInfo
}

func (DirEntry) Info

func (d DirEntry) Info() (fs.FileInfo, error)

func (DirEntry) IsDir

func (d DirEntry) IsDir() bool

func (DirEntry) Name

func (d DirEntry) Name() string

func (DirEntry) Type

func (d DirEntry) Type() fs.FileMode

type File

type File struct {
	F absfs.File
}

func (File) Close

func (f File) Close() error

func (File) Read

func (f File) Read(data []byte) (int, error)

func (File) ReadDir

func (f File) ReadDir(n int) (dirs []fs.DirEntry, err error)

func (File) Stat

func (f File) Stat() (fs.FileInfo, error)

type FileSystem

type FileSystem struct {
	Fs absfs.Filer
}

func NewFs

func NewFs(fs absfs.Filer) (FileSystem, error)

func (FileSystem) Open

func (f FileSystem) Open(name string) (fs.File, error)

func (FileSystem) ReadDir

func (f FileSystem) ReadDir(name string) (dirs []fs.DirEntry, err error)

func (FileSystem) ReadFile

func (f FileSystem) ReadFile(name string) (data []byte, err error)

func (FileSystem) Stat

func (f FileSystem) Stat(name string) (fs.FileInfo, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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