Skip to content

Edwin-Luijten/go_flysystem

Repository files navigation

Go Flysystem

GitHub go.mod Go version Go Reference Build Status Maintainability Test Coverage

Go Flysystem is a filesystem abstraction which allows you to easily swap out a local filesystem for a remote one.

Inspired by: https://github.com/thephpleague/flysystem

Installation

go get github.com/edwin-luijten/go_flysystem

Usage

Adapters

import (
    "github.com/edwin-luijten/go_flysystem/adapter"
)

func main() {
    a, err := adapter.NewLocal("./_testdata")
    if err != nil {
    	panic(err)
    }
    
    // Write
    err = a.Write("test.txt", []byte("hello"))
    if err != nil {
        t.Log(err)
        t.Fail()
    }
}

Multiple adapters

import (
    "github.com/edwin-luijten/go_flysystem/adapter"
)

func main() {
    a, err := adapter.NewLocal("./_testdata")
    if err != nil {
    	panic(err)
    }
    
    b, err = adapter.NewLocal("./_testdata")
    if err != nil {
        panic(err)
    }
    
    fs, err = flysystem.New(a, b)
    
    // Write
    err = fs.Write("test.txt", []byte("hello"))
    if err != nil {
        t.Log(err)
        t.Fail()
    }
}

About

An abstraction layer for local and remote filesystems

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages