跳到主要内容
知仓学习社ZHICANG

go-cli-application-architecture

Design and review maintainable Go CLI application boundaries, package layout, dependency direction, command factories, configuration ownership, adap…

不碰外部(只输出文字)无严重或高危命中hashgraph-online/awesome-codex-plugins

它会碰到什么

扫了多少8 个文本文件,16 KB
它会碰到什么不碰外部(只输出文字)
命中总数0 处
命中统计严重 0 · 高 0 · 中 0 · 低 0

这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。

技能内容

Go CLI Application Architecture

Organize around dependency direction and testable behavior, not a copied folder

template. Keep CLI framework code as an adapter around application services.

Core Workflow

  1. Identify commands, domain actions, external effects, and shared policies.
  2. Separate parsing/rendering from application orchestration and adapters.
  3. Define interfaces at the consumer that needs substitution.
  4. Construct dependencies once in a composition root and pass them explicitly.
  5. Keep configuration immutable after validation; give mutable state a dedicated store.
  6. Record ownership and cleanup for every acquired resource and background task.
  7. Test inward from pure logic to adapters and one assembled executable path.

Read Next

| Task | Load |

|---|---|

| Design or refactor boundaries | guidelines.md, workflows/design-application-boundaries.md |

| Review ownership and cleanup | workflows/review-resource-lifecycle.md |

| Decide package and interface placement | references/application-architecture/rules.md |

| Review patterns and examples | references/application-architecture/examples.md |

| Understand dependency direction | references/application-architecture/knowledge.md |

Guardrails

  • Do not put domain behavior in Cobra Run functions.
  • Avoid a central interfaces package and broad catch-all service abstractions.
  • Do not use package globals or init for dependency construction.
  • Keep fallible I/O and order-dependent startup out of init; use explicit composition.
  • Keep runtime configuration distinct from mutable application storage.
  • Add layers only when they create a real seam, invariant, or dependency boundary.

Source Notes

Guidance is transformed and paraphrased from Marian Montagnino,

Building Modern CLI Applications in Go (Packt, 2023), especially Chapters

2-3, with original adaptations aligned to current Go conventions.

Concrete-first interfaces, dependency ownership, and adapter lifecycle guidance

also incorporates transformed material from Inanc Gumus, *Go by Example:

Programmer's Guide to Idiomatic and Testable Programs* (Manning, 2025),

Chapters 5 and 8-10.

Initialization and lifecycle guidance also incorporates transformed material

from Teiva Harsanyi, 100 Go Mistakes and How to Avoid Them (Manning, 2022),

Chapters 2, 6, 7, and 10.

想直接用这个技能?

本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。

它属于哪个仓库

星标★ 1,027
本站分层T1
该仓技能数1910
原文件路径plugins/LVTD-LLC/skills/skills/go-cli-application-architecture/SKILL.md

同一个仓库里的其他技能

看这个仓库的全部 1910 个技能