Documentation
¶
Overview ¶
Package backend provides a means of allowing backend file systems to self-register on load via an init() call to backend.Register("some name", vfs.FileSystem)
In this way, a caller of vfs backends can simply load the backend file system (and ONLY those needed) and begin using it:
package main
// import backend and each backend you intend to use
import(
"github.com/c2fo/vfs/v7/backend"
"github.com/c2fo/vfs/v7/backend/os"
"github.com/c2fo/vfs/v7/backend/s3"
)
func main() {
var err error
var osfile, s3file vfs.File
// THEN begin using the file systems
osfile, err = backend.Backend(os.Scheme).NewFile("", "/path/to/file.txt")
if err != nil {
panic(err)
}
s3file, err = backend.Backend(s3.Scheme).NewFile("mybucket", "/some/file.txt")
if err != nil {
panic(err)
}
err = osfile.CopyTo(s3file)
if err != nil {
panic(err)
}
}
Development ¶
To create your own backend, you must create a package that implements the interfaces: vfs.FileSystem, vfs.Location, and vfs.File. Then ensure it registers itself on load:
package myexoticfilesystem
import(
...
"github.com/c2fo/vfs/v7"
"github.com/c2fo/vfs/v7/backend"
)
// IMPLEMENT vfs interfaces
...
// register backend
func init() {
backend.Register("exfs", &MyExoticFileSystem{})
}
Then do use it in some other package do
package MyExoticFileSystem
import(
"github.com/c2fo/vfs/v7/backend"
"github.com/acme/myexoticfilesystem"
)
...
func useNewBackend() error {
myExoticFs, err = backend.Backend(myexoticfilesystem.Scheme)
...
}
That's it. Simple.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Backend ¶
func Backend(name string) vfs.FileSystem
Backend returns the backend file system by name
func Register ¶
func Register(name string, v vfs.FileSystem)
Register a new file system in backend map
func RegisteredBackends ¶
func RegisteredBackends() []string
RegisteredBackends returns an array of backend names
func Unregister ¶
func Unregister(name string)
Unregister unregisters a file system from backend map
func UnregisterAll ¶
func UnregisterAll()
UnregisterAll unregisters all file systems from backend map
func ValidateCopySeekPosition ¶
func ValidateCopySeekPosition(f vfs.File) error
ValidateCopySeekPosition return ensures current seek cursor is 0,0. This is useful to ensure it's safe to copy. A seek position elsewhere will mean a partial copy.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package all imports all VFS implementations.
|
Package all imports all VFS implementations. |
|
Package azure Microsoft Azure Blob Storage VFS Implementation
|
Package azure Microsoft Azure Blob Storage VFS Implementation |
|
types
Package types provides types and interfaces for Azure operations.
|
Package types provides types and interfaces for Azure operations. |
|
Package ftp - FTP VFS implementation.
|
Package ftp - FTP VFS implementation. |
|
types
Package types provides types and interfaces for FTP operations.
|
Package types provides types and interfaces for FTP operations. |
|
Package gs - Google Cloud Storage VFS implementation.
|
Package gs - Google Cloud Storage VFS implementation. |
|
Package mem - built-in mem lib VFS implementation.
|
Package mem - built-in mem lib VFS implementation. |
|
Package os - built-in os lib VFS implementation.
|
Package os - built-in os lib VFS implementation. |
|
Package s3 implements vfs.FileSystem for AWS S3.
|
Package s3 implements vfs.FileSystem for AWS S3. |
|
Package sftp - SFTP VFS implementation.
|
Package sftp - SFTP VFS implementation. |
|
Package testsuite is meant to be run by implementors of backends to ensure that the behaviors of their backend matches the expected behavior of the interface.
|
Package testsuite is meant to be run by implementors of backends to ensure that the behaviors of their backend matches the expected behavior of the interface. |