Skip to content

jfontan/go-billy-desfacer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-billy-desfacer GoDocBuild Statuscodecov

go-billy filesystem that wraps afero. It lets use afero filesystems with software that expects go-billy, for example with go-git.

Installation

go get gopkg.in/jfontan/go-billy-desfacer.v0

Example of use

package main

import (
	"fmt"

	"github.com/spf13/afero"
	"gopkg.in/jfontan/go-billy-desfacer.v0"
)

func main() {
	// wrap an afero filesystem to billy interface
	aferofs := afero.NewMemMapFs()
	billyfs := desfacer.New(aferofs)

	// create a file with billy interface
	billyfile, err := billyfs.Create("file")
	if err != nil {
		panic(err)
	}

	_, err = billyfile.Write([]byte("some data"))
	if err != nil {
		panic(err)
	}
	_ = billyfile.Close()

	// read file directly in afero filesystem
	aferofile, err := aferofs.Open("file")
	if err != nil {
		panic(err)
	}

	buf := make([]byte, 32)
	n, err := aferofile.Read(buf)
	if err != nil {
		panic(err)
	}
	_ = aferofile.Close()

	fmt.Println(string(buf[:n]))
}

Notes

  • The functions Symlink and Readlink are not implemented as afero does not have that functionality.

The name

"desfacer" means "to undo" or "to unmake" in Galician and old Spanish.

License

Apache License Version 2.0, see LICENSE.

About

go-billy filesystem wrapper for afero

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published