Mount any
//go:embed
directive file system as a FUSE filesystem
files | ||
.gitignore | ||
embededFUSE_test.go | ||
embededFUSE.go | ||
go.mod | ||
go.sum | ||
LICENSE | ||
README.md |
Go Embedded FUSE Filesystem
Use a Go embedded filesystem as a FUSE filesystem.
Purpose
This package allows you to use a Go embedded filesystem as a FUSE filesystem. This is useful for creating a FUSE filesystem that is self-contained in a single binary.
Use Case
This could allow you to bundle both a binary and its associated files, including an interpreter, in a single binary. This could be useful for creating a single binary that can be run on a system without needing to install any dependencies.
package main
import (
"embed"
"fmt"
gef "git.sdf.org/CRThaze/go-efuse"
)
//go:embed files
var content embed.FS
func main() {
efuse, err := gef.New(EmbeddedFUSEConfig{
EmbedFS: content,
Prefix: "files",
DefaultExecutable: "test.sh",
})
if err != nil {
fmt.Printf("Unable to create Embedded FUSE: %v\n", err)
t.Fail()
}
if err := efuse.Mount(); err != nil {
fmt.Printf("Unable to mount Embedded FUSE:, %v\n", err)
t.Fail()
}
defer func() {
if err := efuse.Unmount(); err != nil {
fmt.Printf("Failed to unmount: %v\n", err)
}
}()
if err := efuse.Execute(); err != nil {
fmt.Printf("Failed to execute: %v\n", err)
}
}