anchors

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

README

internal/anchors

Bootstrap-only package. Holds blank imports for every Go package that wilhelm's code generators introspect, so go.mod keeps those modules available to golang.org/x/tools/go/packages.Load.

Why this exists

The generators (assertgen, envgen) use packages.Load to read the upstream K8s and operator API packages and emit matching assertion structs / typed getters. packages.Load only sees packages that resolve through the current module graph — if no source file imports them, go mod tidy removes them and the next generation produces an empty file.

Before the generated files exist (first-ever generation, or generation in a fresh checkout) we have a chicken-and-egg: the generated file would anchor the deps, but the deps need to be anchored before the file can be generated.

This package solves it with explicit blank imports.

When to edit

Add an entry whenever you add a new package to:

  • the default scan list in assertgen (function defaultPackages), or
  • the assertgenPackages set in envgen.

When not to import this

Never — anchors is internal/, has no exported symbols, and has no runtime effect. The blank imports exist only to satisfy go mod tidy.

Documentation

Overview

Package anchors holds blank imports for every package that wilhelm's generators introspect. The imports keep the modules in `go.mod` and available to golang.org/x/tools/go/packages.Load before the generated files exist (the chicken-and-egg bootstrap problem). The package is otherwise unused at runtime.

Jump to

Keyboard shortcuts

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