Skip to main content
Host UK

DataNode Filesystem (RFC-0016)

Lethean R&D Labs
RFC Filesystem Go In-Memory

DataNode is an in-memory filesystem implementing Go's fs.FS interface. Collect files from anywhere (GitHub, websites, PWAs), manipulate them, serialise to tar or encrypt to TRIX - all without touching disk.

Features

In-Memory

Files exist only in RAM until explicitly serialised

fs.FS Compatible

Works with any Go code expecting a filesystem

Flat Key-Value

Paths are keys, directories are implicit from prefixes

Multi-Source

Collect from GitHub repos, websites, PWAs, local disk

Installation

import "github.com/Snider/Borg/pkg/datanode"

dn := datanode.New()
dn.WriteFile("config.json", []byte("{...}"))
dn.WriteFile("src/main.go", []byte("package main..."))

// Implements fs.FS
data, _ := fs.ReadFile(dn, "config.json")

Usage

Core Type

type DataNode struct {
    files map[string]*dataFile
}

type dataFile struct {
    name    string
    content []byte
    modTime time.Time
}

Serialisation

// To tar
tarBytes := dn.ToTar()

// To encrypted TRIX
trixBytes := dn.ToTrix(password)

// From tar
dn, _ := datanode.FromTar(tarBytes)

More from Lethean R&D Labs

View all projects →

Fancy helping out?

Spotted a bug? Got an idea? We'd love to hear from you.

Read the contributing guide →