mergefs

package module
v0.0.0-...-a114843 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2025 License: AGPL-3.0 Imports: 5 Imported by: 0

README

Go Mergefs

Go Report Card AGPLv3 pkg.go.dev

This module implements a Go filesystem that merges two other filesystem: an upper and a lower filesystem. Directories are merged and the upper filesystem takes precedence.

Documentation

Overview

Package mergefs provides an in-memory filesystem that emulates Linux MergeFS functionality. It combines two filesystems (upper and lower) where the upper filesystem takes precedence.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MergeDir

type MergeDir struct {
	// contains filtered or unexported fields
}

MergeDir is used to merge the two directories from the upper and lower filesystem. It implements snapshot sematic.

func NewMergeDir

func NewMergeDir(upper, lower fs.File) (*MergeDir, error)

func (*MergeDir) Close

func (md *MergeDir) Close() error

Close implements fs.File

func (*MergeDir) Read

func (md *MergeDir) Read([]byte) (int, error)

Read implements fs.File

func (*MergeDir) ReadDir

func (md *MergeDir) ReadDir(n int) (result []fs.DirEntry, rerr error)

func (*MergeDir) Stat

func (md *MergeDir) Stat() (fs.FileInfo, error)

Stat implements fs.File

type MergeFS

type MergeFS struct {
	// contains filtered or unexported fields
}

MergeFS implements fs.FS and fs.ReadDirFS by combining two filesystems. Files in the upper filesystem take precedence over files in the lower filesystem.

func New

func New(upper, lower fs.FS) *MergeFS

New creates a new MergeFS with the given upper and lower filesystems. upper takes precedence over lower when both contain the same file. Both must not be nil.

func (*MergeFS) Open

func (mfs *MergeFS) Open(name string) (fs.File, error)

Open implements io/fs.FS and opens the named file for reading. It first tries the upper filesystem, then falls back to the lower filesystem.

func (*MergeFS) ReadDir

func (mfs *MergeFS) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir implements io/fs.ReadDirFS and reads the named directory and returns a list of directory entries. It merges entries from both upper and lower filesystems, with upper taking precedence.

Jump to

Keyboard shortcuts

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