← Back to Pull requests

Add urfave_cli_no_template build tag #2441

Closed
unknown closed this pull request without merging on Oct 01, 2026 06:59 UTC
View on GitHub
unknown unknown commented on Sep 22, 2026 19:54 UTC
Author

Using text/template disables linker dead code elimination of exported methods for the whole program (golang/go#72895), which can noticeably increase the binary size.

This adds urfave_cli_no_template build tag, which renders the default help and fish completion without text/template, producing the same output.

Custom templates are not supported in this mode:

  • RootCommandHelpTemplate, CommandHelpTemplate, SubcommandHelpTemplate and FishCompletionTemplate are short string constants, only used to tell which help is requested, so modifying them is a compile error;

  • if the default help printer is used with a custom template (such as CustomRootCommandHelpTemplate or CustomHelpTemplate), it panics. A custom template handled by a custom HelpPrinter is fine.
  • With this tag, examples/example-cli is 3.2 MB instead of 5.1 MB, and runc is 10.5 MB instead of 12.4 MB (with opencontainers/runc#5486 applied, which fixes the only other reason DCE is disabled in runc); all 19 help pages of runc are byte-for-byte identical.

    Testing:

  • the existing test suite is run with this tag in CI (skipping custom template tests);

  • a new golden test (TestHelpOutput) renders various help pages and fish completion, making sure both modes produce the exact same output;

  • TestNoTemplateTagDCE makes sure there are no <ReflectMethod> symbols (which disable DCE) in examples/example-cli built with this tag;

  • make check-binary-size now also shows the size with this tag.
  • Closes #2277.

    _An alternative, in which the template-less rendering code is generated from the templates, was proposed in #2442 (now closed)._

    Diff: 212 lines (+159 / -53) across 2 files Reviewer: kolyshkin Review duration: 12185m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 212 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.321
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2441"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.5% (MEDIUM) · Higher = larger blast radius
    36.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14.4% · Safe to merge
    14.4%
    Repository