importclosure

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package importclosure finds every package of a module that a package is built from, for the guards that pin what that code may use.

A guard that scans one directory pins nothing about the packages that directory imports: code that moves into one of them leaves the guard's reach and no test fails. The purity guards of sdk/go/helpers and sdk/go/core therefore scan every package of the module their package imports, directly or through another, as Walk computes it.

It is test support, imported only by _test.go files. Like vectorio it takes no *testing.T and returns errors instead of failing, because a non-test package that imports testing registers the -test.* flags on every binary that links it. It reads import specs with go/parser rather than running the go command, so a guard needs nothing but the source tree.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ModulePath

func ModulePath(root string) (string, error)

ModulePath reads the module path from the go.mod file in root.

func SourceFiles

func SourceFiles(dir string) ([]string, error)

SourceFiles returns the paths of the non-test Go files in dir, in name order.

func Walk

func Walk(root, module, start string) (map[string]string, error)

Walk returns the directory of start and of every package of module that start imports, directly or through another, keyed by import path. root is the module's root directory: an import path module+"/x/y" lives in root/x/y.

Only the imports of non-test files count, so a package that a test alone imports is not part of the closure. A package of the module whose directory is missing or holds no non-test Go file is an error, so an import path mapped wrongly cannot shrink the closure without a failure.

Types

This section is empty.

Jump to

Keyboard shortcuts

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