Help us shape the future of Go! Take the 2026 Go Developer Survey

dirent

package
v0.1.2045 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package dirent decides whether an entry a reader lists is a folder to go into, links included.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsFolder

func IsFolder(dir string, e fs.DirEntry) bool

IsFolder is whether e, an entry listed in dir, is a folder to read into: a folder of its own, or a link that leads to one. os.ReadDir reports a symlink as ModeSymlink and, on Windows, a junction as ModeIrregular (Go 1.23 and later), and neither as IsDir, so a reader that goes into only IsDir() entries, or IsDir() and ModeSymlink ones, walks past a folder kept on another drive with a junction left where it was (#2268). Such an entry is followed with os.Stat. A link to a file, a broken link and anything else irregular are no folder.

It follows only the entry it is asked about. A reader that recurses on it must keep its own record of the folders it has been in.

Types

type Entry added in v0.1.1664

type Entry struct {
	Name string
	Stat
}

Entry is one entry of a Listing.

type Listing added in v0.1.1664

type Listing []Entry

Listing is a folder's entries in name order. It is a slice, not a map: every 15 s Sessions poll lists every Codex day folder and Claude Code project again, and a map of each folder's entries was ~90 MB of the 2.3 GB eight polls allocated.

func Stats added in v0.1.1651

func Stats(dir string) (Listing, bool)

Stats is each entry of dir in name order, as os.Lstat gives it, read in a few calls for the whole folder where the system has them (getattrlistbulk on macOS), rather than one per entry. ok is false where the system has none or the folder couldn't be read, and the caller asks after each entry itself.

func (Listing) Get added in v0.1.1664

func (l Listing) Get(name string) (Stat, bool)

Get is name's entry.

type Stat added in v0.1.1651

type Stat struct {
	Mode fs.FileMode
	Size int64
	Mod  time.Time
}

Stat is what a folder's listing says of one entry: its kind (Mode's type bits, 0 for a regular file), and a regular file's size and modification time, as os.Lstat gives them.

Jump to

Keyboard shortcuts

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