Use Modern Go

jetbrains/go-modern-guidelines/plugin/skills/use-modern-go

作者 jetbrains155dc7ca10da无许可证3.7K 个星标收录于 2026年10月8日更新于 2026年10月8日仓库4周前更新

Use the Modern Go Guidelines CLI whenever writing, modifying, fixing, or refactoring Go code. Apply its version-specific guidance to generated changes.

AI 生成的概览

运行 Modern Go Guidelines CLI,在编辑 Go 代码时提供特定版本的 Go 惯用写法指导。

功能
该技能封装了 Modern Go Guidelines CLI,首次使用时会将其安装到本地缓存目录。它提供 list 子命令,根据目标 Go 版本返回适用的指南,版本可从 go.mod、go.work、本地工具链或显式覆盖参数解析;还提供 explain 子命令,针对特定指南 ID 给出详细说明和示例。代理被要求完整阅读 list 输出,并将返回的指南应用到正在编写或重构的 Go 代码中。该技能附带 shell 与 PowerShell 包装脚本以及一个 VERSION 文件。
适用场景
在编写、修改、修复或重构 Go 代码,且需要了解可能晚于模型知识截止时间的现代惯用写法时使用。也适用于在改动前确认某个 Go 文件或版本适用哪些指南。
运行要求
可在 Linux、macOS 或 Windows 上通过 shell 或 PowerShell 运行。首次使用时包装脚本会把 Modern Go Guidelines CLI 安装到本地缓存目录,因此需要网络访问。技能附带可执行脚本(run-tool.sh、run-tool.ps1)和一个 VERSION 文件。具备 go.mod、go.work 或本地 Go 工具链的 Go 项目有助于解析目标版本,也可以直接传入显式版本。

Modern Go Guidelines CLI

Always write modern, idiomatic Go code. Use the Modern Go Guidelines CLI as the source of truth for modern Go idioms that may be newer than your knowledge cutoff.

Command:

  • Linux or macOS: sh "<skill-dir>/scripts/run-tool.sh"
  • Windows PowerShell: & '<skill-dir>\scripts\run-tool.ps1'

First run and approvals:

On first use, the wrapper installs the Modern Go Guidelines CLI in a local cache directory.

Subcommands:

  • list
  • explain

Before editing Go code:

  1. Call the wrapper's list subcommand for the relevant Go file.

    Prefer passing the file you are about to edit:

    sh
    sh "<skill-dir>/scripts/run-tool.sh" list --file-path path/to/file.go

    On Windows, use the PowerShell wrapper with the same arguments.

    The CLI resolves the applicable Go version from go.mod, go.work, the local Go toolchain, or an explicit override.

  2. If the target Go version is already known, you may pass it directly:

    sh
    sh "<skill-dir>/scripts/run-tool.sh" list --go-version 1.24
  3. Read the complete list output before deciding which guidelines apply.

    The list output is ordered newest first. Read the full output because older supported guidelines may still apply.

    Do not pipe the output through head, tail, grep, sed, or any other truncating/filtering command. Important guidelines may otherwise be missed.

  4. Treat returned guidelines as authoritative for modern Go style choices in code you are editing.

    If a guideline applies, follow it even when nearby code or repository convention uses an older pattern. Skip it only when it would not compile, would change behavior, or clearly does not match the edited code. Before skipping a returned guideline that seems relevant, call the wrapper's explain subcommand for that guideline ID.

Call explain only when a specific guideline may apply and you need the detailed explanation or examples. Request only the guideline IDs you intend to evaluate or apply:

sh
sh "<skill-dir>/scripts/run-tool.sh" explain sync_waitgroup_go

Multiple guideline IDs may be requested as positional arguments:

sh
sh "<skill-dir>/scripts/run-tool.sh" explain atomic_types errors_as_type

Do not call explain without guideline IDs. Use list first to discover the short guideline list for the target Go version, then call explain for the specific returned IDs that need more context.

来源与署名

来源:jetbrains/go-modern-guidelines位于plugin/skills/use-modern-go提交155dc7c

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架