MCPcopy Index your code
hub / github.com/go-git/go-billy

github.com/go-git/go-billy @v5.9.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v5.9.0 ↗ · + Follow
632 symbols 2,437 edges 45 files 105 documented · 17% 147 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

go-billy GoDoc Test

The missing interface filesystem abstraction for Go. Billy implements an interface based on the os standard library, allowing to develop applications without dependency on the underlying storage. Makes it virtually free to implement mocks and testing over filesystem operations.

Billy was born as part of go-git/go-git project.

Version support

go-billy v5 is in maintenance mode. Users should upgrade to go-billy v6 where possible.

Installation

import "github.com/go-git/go-billy/v5" // with go modules enabled (GO111MODULE=on or outside GOPATH)
import "github.com/go-git/go-billy" // with go modules disabled

Usage

Billy exposes filesystems using the Filesystem interface. Each filesystem implementation gives you a New method, whose arguments depend on the implementation itself, that returns a new Filesystem.

The following example caches in memory all readable files in a directory from any billy's filesystem implementation.

func LoadToMemory(origin billy.Filesystem, path string) (*memory.Memory, error) {
    memory := memory.New()

    files, err := origin.ReadDir("/")
    if err != nil {
        return nil, err
    }

    for _, file := range files {
        if file.IsDir() {
            continue
        }

        src, err := origin.Open(file.Name())
        if err != nil {
            return nil, err
        }

        dst, err := memory.Create(file.Name())
        if err != nil {
            return nil, err
        }

        if _, err = io.Copy(dst, src); err != nil {
            return nil, err
        }

        if err := dst.Close(); err != nil {
            return nil, err
        }

        if err := src.Close(); err != nil {
            return nil, err
        }
    }

    return memory, nil
}

Why billy?

The library billy deals with storage systems and Billy is the name of a well-known, IKEA bookcase. That's it.

License

Apache License Version 2.0, see LICENSE

Extension points exported contracts — how you extend this code

Basic (Interface)
Basic abstract the basic operations in a storage-agnostic interface as an extension to the Basic interface. [6 implementers]
fs.go
Option (FuncType)
(no doc)
osfs/os_options.go
Dir (Interface)
Dir abstract the dir related operations in a storage-agnostic interface as an extension to the Basic interface. [7 implementers]
fs.go
Symlink (Interface)
Symlink abstract the symlink related operations in a storage-agnostic interface as an extension to the Basic interface. [7 …
fs.go
Chmod (Interface)
Chmod abstracts the logic around changing file modes. [6 implementers]
fs.go
Capable (Interface)
Capable interface can return the available features of a filesystem. [7 implementers]
fs.go

Core symbols most depended-on inside this repo

Join
called by 191
fs.go
Symlink
called by 94
fs.go
Stat
called by 83
fs.go
Name
called by 76
fs.go
newBoundOS
called by 63
osfs/os_bound.go
WriteFile
called by 57
util/util.go
Close
called by 47
test/mock.go
Open
called by 44
fs.go

Shape

Method 437
Function 130
Struct 48
Interface 13
TypeAlias 3
FuncType 1

Languages

Go100%

Modules by API surface

memfs/memory.go54 symbols
test/basic.go43 symbols
helper/chroot/chroot_test.go41 symbols
helper/mount/mount_test.go39 symbols
fs.go37 symbols
helper/chroot/chroot.go36 symbols
test/mock.go30 symbols
osfs/os_bound.go26 symbols
helper/mount/mount.go26 symbols
osfs/os_bound_test.go22 symbols
osfs/os_chroot.go19 symbols
test/symlink.go18 symbols

For agents

$ claude mcp add go-billy \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page