Skip to content
rlsbl.targets.go
On this page

Go release target using a VERSION file as source of truth with GoReleaser integration for binaries, module proxy notification, and retract support.

#rlsbl.targets.go

#rlsbl.targets.go

Go release target using a VERSION file as source of truth, with GoReleaser integration for binaries and module proxy notification for libs.

#_go_archive_fn

python
def _go_archive_fn(spec, name)

Return (asset_pattern, extract_cmd, binary_name) for a Go/goreleaser build.

#GoTarget

Release target for Go projects (go.mod + VERSION file).

#name

python
def name(self)

#rewrite_mirror_identity

python
def rewrite_mirror_identity(self, clone_dir, mirror_remote)

Move this clone's module path onto the mirror repository's identity.

The new path is what the MIRROR's remote states -- host/owner/repo -- because that is the URL go get will resolve against once the mirror is the package's public home. The rewrite itself is the one rlsbl rewrite go-module-path performs: the module directive, every cross-module reference to it, and every import site, all token-bounded so a neighbouring module whose path merely starts with the same letters is left alone.

Two refusals, both hard, because either would leave a go.mod that does not resolve:

  • a mirror remote whose URL names no module host (a local path, an SSH

alias with no dot in it) -- there is no identity to rewrite TO;

  • a clone with no go.mod declaring a module path -- there is nothing to

rewrite FROM.

#read_name

python
def read_name(self, dir_path, ctx)

Read the last segment of the module path from go.mod.

#publication_probe

python
def publication_probe(self, dir_path, version, ctx=None)

Probe for a specific version by checking tag existence via git.

Uses git ls-remote --tags origin <tag> instead of the Go module proxy: tag existence is the authoritative signal for Go module publication (the proxy indexes from tags). This avoids proxy cache lag and works for private modules.

#cached_registry_probe

python
def cached_registry_probe(self, dir_path, version, ctx=None)

Ask proxy.golang.org whether it serves this module version.

The counterpart to :meth:publication_probe, which asks the git remote about the tag. The proxy is a permanent cache: once anyone resolves a module version it is served forever, whatever later happens to the tag. So the proxy serving a version is decisive evidence that it is out in the world, and the proxy NOT serving one is no evidence at all -- it indexes lazily, and a genuinely published version nobody has fetched is absent from it.

#_is_library

python
def _is_library(self, dir_path, config=None)

Return True when the project publishes a Go module, not a binary.

The go pipeline's artifact key is the operator's committed choice and is AUTHORITATIVE -- validate_pipelines_config makes it mandatory precisely because the two kinds produce different publish workflows and a wrong guess yields a broken one. Filesystem introspection only answers when nothing is declared (a project's very first scaffold, before _ensure_pipeline_config writes the key).

Scanning for package main anywhere in the tree misclassifies a declared library that ships a dev helper under scripts/: scaffold wrote a .goreleaser.yml aimed at the helper plus a version.go inside it, while the publish workflow -- which does read the declaration -- correctly ran no goreleaser job.

#_has_version_var

python
def _has_version_var(self, dir_path, main_dir='.')

Return True if a .go file in main_dir declares a Version variable.

#read_version

python
def read_version(self, dir_path)

Read version from the VERSION file.

#write_version

python
def write_version(self, dir_path, version, ctx)

Write the new version to the VERSION file.

Returns a list of relative file paths that were modified.

#version_file

python
def version_file(self, dir_path=None)

Return the version file name for Go projects.

#tag_format

python
def tag_format(self, version)

Return the git tag string for a Go release version.

#companion_tags

python
def companion_tags(self, name, version, path=None)

Return Go module proxy companion tags for monorepo packages.

When path is set (monorepo member), the Go module proxy needs a tag of the form {path}/v{version} to resolve the module. This tag is identical to the Go target's primary monorepo_tag_format output, so it is only useful as a companion when a different target (e.g. npm) is the primary release target and produces a non-Go-compatible primary tag.

The repository ROOT contributes none: a root module's proxy tag is v{version} itself, which is the primary the release already creates. Prefixing the root's path spelling would ask git to create ./v{version}, which is not a legal ref name at all.

#monorepo_tag_format

python
def monorepo_tag_format(self, name, version, path=None)

Return a Go module proxy compatible tag using the package path prefix.

A root module carries no prefix -- its proxy tag is the standalone v{version}.

#monorepo_tag_glob

python
def monorepo_tag_glob(self, name, path=None)

Return a glob pattern matching Go module proxy tags for a monorepo package.

#_path_sep

python
def _path_sep(path)

The separator between a member path and the v{version} segment.

#template_dir

python
def template_dir(self)

Return the path to the Go-specific template directory.

#template_vars

python
def template_vars(self, dir_path, ctx)

Extract template variables from go.mod and .rlsbl/config.json.

#template_mappings

python
def template_mappings(self, ctx)

Return Go template mappings including VERSION, CI, goreleaser, and version.go.

#shared_template_mappings

python
def shared_template_mappings(self, ctx)

Return shared mappings plus npm wrapper mappings if enabled.

#check_project_exists

python
def check_project_exists(self, dir_path)

Return True if go.mod exists in dir_path.

#get_project_init_hint

python
def get_project_init_hint(self)

Return a hint for initializing a Go module.

#dev_install_command

python
def dev_install_command(self, project_dir)

Return install specs for go install using declared install_paths.

#registry_display_name

python
def registry_display_name(self)

#run_tests

python
def run_tests(self, *, project_dir=None, workspace_root=None, skip_sync=False, config=None, check_timeout=None)

Run go test ./....

#find_dead_modules

python
def find_dead_modules(self, root, *, exclude_dirs=None, suppress=frozenset())

Union-of-imports detector over the module's internal packages.

#normalize_package_name

python
def normalize_package_name(self, raw_name)

Go compares the last segment of a module path, lowercased.

#query_latest_version

python
def query_latest_version(self, name)

Ask the Go module proxy for the latest published version.

#yank

python
def yank(self, project_dir, version, tag, *, reason=None, dry_run=False)

Add a retract directive for a version to go.mod.

The module proxy is permanent -- a published version can never be removed, only retracted, and the retraction itself only takes effect once a LATER version carrying the directive is published.

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