← All notes

Go testing/fstest: test helpers for file systems

Answer: Package fstest implements support for testing implementations and users of file systems.

TestFS

TestFS tests a file system implementation.

Otherwise a file system must contain at least the listed files, and it can also contain others.

It also checks that the file system contains at least the expected files.

The contents of the file system must not change concurrently with TestFS.

As a special case, if no expected files are listed, the file system must be empty.

MapFS in the source

A MapFS is a simple in-memory file system for use in tests.

Open opens the named file after following any symbolic links.

Lstat makes no attempt to follow the link.

A MapFile describes a single file in a MapFS.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Go Authors, testing/fstest; The Go Authors, testing/fstest source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Go Authors, testing/fstest; The Go Authors, testing/fstest source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.

Cite this

Permanent ID: iil:note:chyw7ag0

iinventedlight. 2026. "Go testing/fstest: test helpers for file systems." iinventedlight Library, iil:note:chyw7ag0, version of 2026-11-24. https://iinventedlight.com/library/notes/go-fstest/. License: CC-BY-4.0.

@misc{iil_note_chyw7ag0,
  author = {{iinventedlight}},
  title = {{Go testing/fstest: test helpers for file systems}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-24},
  url = {https://iinventedlight.com/library/notes/go-fstest/},
  note = {Permanent ID iil:note:chyw7ag0. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-fstest.md.