vfs

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package vfs exposes any Go io/fs.FS implementation as a read-only SQLite VFS, so an embed.FS or zip-backed FS can be opened as a database without touching the real filesystem.

import (
    "embed"
    "database/sql"
    _ "github.com/go-again/sqlite"
    "github.com/go-again/sqlite/vfs"
)

//go:embed seed.db
var seed embed.FS

func main() {
    name, _, _ := vfs.New(seed)
    db, _ := sql.Open("sqlite3", "file:seed.db?vfs="+name)
    // ...
}

This package is a thin re-export of modernc.org/sqlite/vfs; the underlying C bridge is platform-specific and transpiled per-target by modernc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

type FS = mvfs.FS

FS is the type returned by New. It satisfies the SQLite VFS interface and holds the registered name for the lifetime of the program.

func New

func New(f fs.FS) (string, *FS, error)

New registers fs as a read-only SQLite VFS and returns the name to pass via the DSN ?vfs=<name> parameter. The returned *FS retains the VFS for the lifetime of the program.

New is concurrency-safe; multiple calls register independent VFS instances. Open a database against this VFS by adding ?vfs=<name> to the DSN.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL