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

modfiles

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package modfiles enumerates Go source files owned by this module while excluding structural directories and nested repository or module boundaries.

Index

Constants

View Source
const (
	// ReasonVendor is a vendored dependency tree. No repository in this
	// workspace vendors; Go also ignores vendor/ when a workspace is active.
	ReasonVendor = "vendor"
	// ReasonTestdata is Go's testdata convention: never part of a build.
	ReasonTestdata = "testdata"
	// ReasonDotPrefixed and ReasonUnderscorePrefixed are the names the Go tool
	// itself ignores, which is why they are sound to skip here.
	ReasonDotPrefixed        = "dot-prefixed"
	ReasonUnderscorePrefixed = "underscore-prefixed"
)

The reasons the walk refuses a path. They are exported because a guard that polices this walk must be able to report WHICH rule hid a file, and must be unable to fall behind when a rule is added.

Variables

This section is empty.

Functions

func BoundaryMarkers

func BoundaryMarkers() []string

BoundaryMarkers returns the marker filenames that stop the walk at a nested module or repository. The slice is a copy: a caller pinning this set must not be able to change it.

It is exported so a guard can enumerate the markers rather than restate them. A restated copy is a second implementation of "what is a boundary", and two such implementations have already disagreed here: one recognised only a .git DIRECTORY while this walk stops at a .git FILE too, which is what `git submodule add` and `git worktree add` write.

func Files

func Files(root string) ([]string, error)

Files returns absolute paths to every module-owned Go source file below root. Build constraints are deliberately ignored so tagged production files remain visible to dependency and formatting checks.

func IgnoredDirectory

func IgnoredDirectory(name string) (string, bool)

IgnoredDirectory reports whether the walk refuses to descend into a directory with this name, and why.

The reason is returned, not just the verdict, because a guard reporting a hidden subtree must say which rule hid it — and because a rule added here without a reason cannot be reported at all, which is the failure this signature exists to make impossible.

func IgnoredFile

func IgnoredFile(name string) (string, bool)

IgnoredFile reports whether the walk refuses to read a file with this name, and why. Go ignores these names too, so a Go file behind one is not part of any build.

func WriteNull

func WriteNull(w io.Writer, paths []string) error

WriteNull writes paths separated and terminated by NUL bytes for safe piping to tools such as xargs -0, including when a filename contains whitespace or newlines.

Types

type SymlinkError

type SymlinkError struct {
	Path string
}

SymlinkError reports a module-owned Go source path that is a symbolic link. Discovery fails closed rather than following a link that may escape the module.

func (*SymlinkError) Error

func (e *SymlinkError) Error() string

Directories

Path Synopsis
cmd
modfiles command

Jump to

Keyboard shortcuts

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