Skip to content
rlsbl.go_introspect
On this page

Toolchain-backed Go project introspection via ``go list``, classifying projects as library or binary and resolving module paths and import dependencies.

#rlsbl.go_introspect

#rlsbl.go_introspect

Toolchain-backed Go project introspection via go list, classifying projects as library or binary and resolving module paths and import dependencies.

Single source of truth for project-level Go classification (library vs binary, entry-point location). Hand-rolled main.go globbing misdetects real layouts: entry files not named main.go (cmd/x/cli.go), _test.go files in package main dirs, and broken-root layouts (a root package main file with no func main next to a real main under cmd/). The go toolchain handles all of these correctly, so it is the source of truth -- callers must never fall back to file scanning.

#GoIntrospectError

Go project introspection failed (missing toolchain, missing go.mod, go list failure, or an unresolvable main-package layout).

#GoPackage

A Go package as reported by go list.

#list_packages

python
def list_packages(project_dir: str) -> list[GoPackage]

Enumerate all packages in the Go module rooted at project_dir.

Runs go list -e -f ... ./.... The -e flag reports packages even when their imports don't resolve (no network or go.sum needed); error pseudo-packages (empty package name) are skipped.

Raises GoIntrospectError if the go binary is missing, project_dir has no go.mod, or go list fails. Never silently returns an empty list for those conditions -- callers decide fatality.

#list_main_packages

python
def list_main_packages(project_dir: str) -> list[GoPackage]

Enumerate package main packages (binaries) in a project.

#_pipeline_entries

python
def _pipeline_entries(config: dict) -> dict

The config's pipelines map, or {} when it declares none.

A pipelines value that is present but not a map is a config error, not something to iterate: "pipelines": "none" is truthy, and .values() on it raised an AttributeError that named no config key. load_pipelines owns the diagnosis, so this defers to it rather than restating the message.

#go_pipeline_artifact

python
def go_pipeline_artifact(config: dict) -> str | None

Return the artifact declared on the config's go-type pipeline.

None when the config declares no go pipeline, or the pipeline carries no artifact key (only possible before the key is written -- it is mandatory once validated). The declared value is authoritative everywhere: it decides the publish template AND what scaffold writes, so detection never overrides it.

#go_pipeline_install_paths

python
def go_pipeline_install_paths(config: dict) -> list[str] | None

Read install_paths declared on the go-type pipeline entry.

Returns the declared list, or None when no go pipeline declares one. Raises GoIntrospectError if the declaration is not a non-empty list of strings.

#_normalize_rel

python
def _normalize_rel(path: str) -> str

Normalize a declared install path to the helper's rel_dir form.

#validate_install_paths

python
def validate_install_paths(project_dir: str, paths: list[str]) -> list[str]

Validate that every declared install path is a main package.

Returns the normalized paths. Raises GoIntrospectError naming the offending path and listing what go list actually detected.

#describe_main_packages

python
def describe_main_packages(mains: list[GoPackage]) -> str

Human-readable summary of detected main packages for error messages.

#resolve_main_package_dir

python
def resolve_main_package_dir(project_dir: str, config: dict) -> str

Resolve THE main package dir for single-binary concerns (goreleaser main:, version.go placement).

Resolution order:

  1. install_paths declared on the go pipeline: must contain exactly

one path, which must be a main package.

  1. No declaration: exactly one detected main package is used.

Anything else (zero mains, multiple mains without a declaration, multiple declared paths) is a hard error listing what go list detected, so fixing the config is a copy-paste.

More tools from this site

  • claudestream Drive Claude Code from Python: run it as a subprocess and read its output as typed events, with async and sync sessions, sandbox policies, and tools you define in Python
  • claudewheel A TUI Claude Code Launcher that lets you have more than one profile, manage sessions lifecycle, pick the exact CC version, model to use (even older unlisted ones), pick which GitHub account to use, etc.
  • dirstat Fast, single-binary directory statistics CLI: every file under a tree grouped by format, with counts, sizes, and lines of code, as a colored terminal table or as JSON
  • fastware A batteries-included ASGI framework: msgspec JSON, a managed Granian server, dependency injection, SSE, WebSockets, auth, and a test client
  • go-toml-edit Zero-dep TOML editing library for Go with comment preservation
  • howmuchleft The fastest Claude Code statusline: context window, 5-hour, and weekly limit usage as three customizable gradient bars, rendering in about 6 ms
  • orxtra
  • pgdesign
  • predraw Declarative rendering pipeline: describe a scene in JSON and get SVG, PNG and WebP out, with light and dark style tokens, reusable components and text converted to path outlines
  • reposummary Turn a git repository's history into a Markdown journal: pick a time window or revision range and get a readable digest of what changed, optionally narrated by an LLM
  • safegit git wrapper CLI that gives each commit its own temporary index and retries ref updates on conflict, so concurrent agents share one repository
  • saferm Command-line replacement for rm that archives every deletion with a mandatory reason and the context it ran in, so deleted files can be listed, inspected and restored
  • selfdoc Static Site Generator that builds a project's documentation site directly from its source code, so the docs can never drift from the code they describe, with SEO/AEO, first-class blog, search, and cross-project linking built in
  • strictcli
  • stricttest An always-on test-isolation floor: a pytest plugin and a Go env-hygiene module that make a test suite structurally unable to reach real credentials, the real HOME, the network, or the development repository.
  • wesktop A Python framework that turns an ASGI web app into a desktop application, serving it from a local Granian server and displaying it in a native OS window via pywebview
Search