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

modfiles

package
v0.7.1 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

This section is empty.

Variables

This section is empty.

Functions

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 IsBoundaryDirectory

func IsBoundaryDirectory(dir string) (bool, error)

IsBoundaryDirectory reports whether dir is owned by a different module or repository, and is therefore not this module's content. It is exported for the same reason IsIgnoredDirectoryName is: it is the definition of a boundary, and there must be exactly one.

func IsIgnoredDirectoryName

func IsIgnoredDirectoryName(name string) bool

IsIgnoredDirectoryName reports whether a directory with this name is excluded from enumeration: vendor and testdata, which the Go tool does not build as module content, and any name the Go tool itself ignores.

It is EXPORTED because a second walk over the same tree must exclude exactly what this one excludes. It was not, and the consequence was a copy: the dependency guard's nested-module walk retyped these literals and carried a comment claiming the two could not disagree. They could — widening this function alone silently un-guarded a directory in both walks at once, and two mutants survived the whole suite proving it. Callers share the predicate now; the SET it returns is pinned separately, because sharing makes the two walks agree without stopping the shared answer from being widened.

This package has THREE structural predicates, not two, and the seam is only as good as the count: IsIgnoredFileName is the third, and it was left unshared and unpinned for a round while a comment here claimed the exclusions were exactly mirrored. Any predicate that decides what a walk does not see belongs in this exported set and needs an oracle in the consumer.

func IsIgnoredFileName

func IsIgnoredFileName(name string) bool

IsIgnoredFileName reports whether a file with this name is excluded from enumeration. It is exported for the same reason the two directory predicates are, and it was the one left behind when they were shared: widening it hides a file from the dependency guard AND from `make fmt-check`, which pipes this same enumerator into gofmt. A mutant adding a "_generated.go" suffix here survived the whole suite and the whole check — the escaped file was unformatted, unchecked and unguarded at once.

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