vfsafero

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2019 License: MIT Imports: 3 Imported by: 3

README

go-vfsafero

GoDoc Build Status Report Card

Package vfsafero provides a compatibility later between github.com/twpayne/go-vfs and github.com/spf13/afero.

This allows you to use vfst to test exisiting code that uses afero.Fs, and use vfs.FSs as afero.Fss. See the documentation for an example.

License

MIT

Documentation

Overview

Package vfsafero provides a compatibility later between github.com/twpayne/go-vfs and github.com/spf13/afero.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AferoFS

type AferoFS struct {
	vfs.FS
}

An AferoFS implements github.com/spf13/afero.Fs.

func NewAferoFS

func NewAferoFS(fs vfs.FS) *AferoFS

NewAferoFS returns a new AferoFS.

Example
package main

import (
	"testing"

	"github.com/spf13/afero"
	"github.com/twpayne/go-vfs/vfst"

	vfsafero "github.com/twpayne/go-vfsafero"
)

func main() {
	Test := func(t *testing.T) {
		fs, cleanup, err := vfst.NewTestFS(map[string]interface{}{
			"/home/user/.bashrc": "# contents of .bashrc\n",
		})
		if err != nil {
			t.Fatal(err)
		}
		defer cleanup()

		aferoFS := vfsafero.NewAferoFS(fs)
		afero.WriteFile(aferoFS, "/home/user/foo", []byte("bar"), 0666)

		vfst.RunTests(t, fs, "",
			vfst.TestPath("/home/user/foo",
				vfst.TestContentsString("bar"),
			),
		)
	}

	Test(&testing.T{})
}
Output:

func (*AferoFS) Create

func (a *AferoFS) Create(name string) (afero.File, error)

Create implements afero.Fs.Create.

func (*AferoFS) LstatIfPossible

func (a *AferoFS) LstatIfPossible(name string) (os.FileInfo, bool, error)

LstatIfPossible implements afero.Lstater.LstatIfPossible.

func (*AferoFS) MkdirAll

func (a *AferoFS) MkdirAll(path string, perm os.FileMode) error

MkdirAll implements afero.Fs.MkdirAll.

func (*AferoFS) Name

func (a *AferoFS) Name() string

Name implements afero.Fs.Name.

func (*AferoFS) Open

func (a *AferoFS) Open(name string) (afero.File, error)

Open implements afero.Fs.Open.

func (*AferoFS) OpenFile

func (a *AferoFS) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error)

OpenFile implements afero.Fs.OpenFile.

Jump to

Keyboard shortcuts

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