package fsys
import "cmd/go/internal/fsys"
Package fsys implements a virtual file system that the go command uses to read source file trees. The virtual file system redirects some OS file paths to other OS file paths, according to an overlay file. Editors can use this overlay support to invoke the go command on temporary files that have been edited but not yet saved into their final locations.
Index ¶
- Variables
- func Actual(name string) string
- func Bind(dir, mtpt string)
- func Glob(pattern string) (matches []string, err error)
- func Init() error
- func IsDir(path string) (bool, error)
- func IsGoDir(name string) (bool, error)
- func Lstat(name string) (fs.FileInfo, error)
- func Open(name string) (*os.File, error)
- func ReadDir(name string) ([]fs.DirEntry, error)
- func ReadFile(name string) ([]byte, error)
- func Replaced(name string) bool
- func Stat(name string) (fs.FileInfo, error)
- func Trace(op, path string)
- func WalkDir(root string, fn fs.WalkDirFunc) error
Variables ¶
var OverlayFile string
OverlayFile is the -overlay flag value. It names a file containing the JSON for an overlayJSON struct.
Functions ¶
func Actual ¶
Actual returns the actual file system path for the named file. It returns the empty string if name has been deleted in the virtual file system.
func Bind ¶
func Bind(dir, mtpt string)
Bind makes the virtual file system use dir as if it were mounted at mtpt, like Plan 9's “bind” or Linux's “mount --bind”, or like os.Symlink but without the symbolic link.
For now, the behavior of using Bind on multiple overlapping mountpoints (for example Bind("x", "/a") and Bind("y", "/a/b")) is undefined.
func Glob ¶
Glob is like filepath.Glob but uses the overlay file system.
func Init ¶
func Init() error
Init initializes the overlay, if one is being used.
func IsDir ¶
IsDir returns true if path is a directory on disk or in the overlay.
func IsGoDir ¶
IsGoDir reports whether the named directory in the virtual file system is a directory containing one or more Go source files.
func Lstat ¶
Lstat returns a FileInfo describing the named file in the virtual file system. It does not follow symbolic links
func Open ¶
Open opens the named file in the virtual file system. It must be an ordinary file, not a directory.
func ReadDir ¶
ReadDir reads the named directory in the virtual file system.
func ReadFile ¶
ReadFile reads the named file from the virtual file system and returns the contents.
func Replaced ¶
Replaced reports whether the named file has been modified in the virtual file system compared to the OS file system.
func Stat ¶
Stat returns a FileInfo describing the named file in the virtual file system. It follows symbolic links.
func Trace ¶
func Trace(op, path string)
Trace emits a trace event for the operation and file path to the trace log, but only when $GODEBUG contains gofsystrace=1. The traces are appended to the file named by the $GODEBUG setting gofsystracelog, or else standard error. For debugging, if the $GODEBUG setting gofsystracestack is non-empty, then trace events for paths matching that glob pattern (using path.Match) will be followed by a full stack trace.
func WalkDir ¶
func WalkDir(root string, fn fs.WalkDirFunc) error
WalkDir is like filepath.WalkDir but over the virtual file system.
Source Files ¶
- Version
- v1.24.0 (latest)
- Published
- Feb 10, 2025
- Platform
- linux/amd64
- Imports
- 20 packages
- Last checked
- 29 minutes ago –
Tools for package owners.