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 從公開儲存庫中收錄這些內容。

檢舉或申請下架