Mount any //go:embed directive file system as a FUSE filesystem
Go to file
2024-07-06 22:37:27 +02:00
files basic structure of idea 2024-07-03 14:13:40 +02:00
.gitignore Initial commit 2024-06-25 15:01:21 +00:00
embededFUSE_test.go use fuse tree & ioctl compatible fork 2024-07-06 22:19:06 +02:00
embededFUSE.go docs 2024-07-06 22:37:27 +02:00
go.mod use fuse tree & ioctl compatible fork 2024-07-06 22:19:06 +02:00
go.sum use fuse tree & ioctl compatible fork 2024-07-06 22:19:06 +02:00
LICENSE Initial commit 2024-06-25 15:01:21 +00:00
README.md docs 2024-07-06 22:37:27 +02:00

Go Embedded FUSE Filesystem

Go Reference

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)
	}
}