Group
GoLand
- Repository on GitHub: Fashionable Go Pointers.
- Goal: Fashionable Go Pointers are a set of expertise that assist AI coding brokers write up-to-date Go code that matches the Go model in your venture.
- Model help: The talents cowl helpful language options and commonplace library additions from Go 1.0 via Go 1.27. Pointers for newer variations are excluded when your venture makes use of an older model.
- Targeted context: The device makes use of
recordfor brief pointers andclarifyfor detailed examples. This progressive disclosure method provides brokers detailed steering solely once they want it and helps them apply the talents extra reliably. - Set up: You possibly can set up the plugin from {the marketplace} or an area repository. The mixing requires the Go toolchain, runs from an area cache, and doesn’t modify your venture.
AI coding brokers can produce working Go code, however they sometimes depend on outdated patterns. Older syntax seems extra typically of their coaching knowledge. Newer language options and commonplace library additions may additionally fall outdoors their coaching cutoff.
The GoLand staff created Fashionable Go Pointers to shut this hole. These Golang expertise give brokers an up-to-date reference for writing trendy code. They assist brokers choose options supported by the Go model in your venture and keep away from code that requires a more moderen model.
Fashionable Golang expertise are an open-source contribution from the GoLand staff to the broader Go group. You should utilize them with supported AI coding brokers within the terminal.Â
Newer code is helpful solely when your venture can compile it. For that reason, the rules match the Go model declared in your go.mod file.
Think about a venture that accommodates the go 1.25 directive.
The agent can obtain expertise for Go 1.25 and earlier. It doesn’t obtain Go 1.26 or Go 1.27 expertise. For instance, it might study to make use of sync.WaitGroup.Go, which Go 1.25 launched. It is not going to obtain a suggestion to make use of errors.AsType, which requires Go 1.26.
This model test ensures that the generated code is suitable along with your venture. It additionally reduces the quantity of context the agent should learn. The agent doesn’t spend tokens on options that it can not use.
CLI device with targeted output
The agent makes use of a CLI device that comes with the go-modern-guidelines plugin. It contains the use-modern-go ability, a set of directions that teaches the agent when and find out how to use the CLI. The device helps two fundamental subcommands: record and clarify. The ability tells the agent to run record for the related Go file earlier than modifying and to name clarify when it wants particulars a couple of particular rule.
Every agent integration runs these subcommands via its personal wrapper. The examples beneath use the CLI binary identify.
Your agent makes use of the CLI to get expertise for the Go model(s) utilized in your venture. The record subcommand returns brief, related pointers. When the agent wants extra context, the clarify subcommand offers detailed steering and code examples.
go-modern-guidelines record --file-path ./inside/employee/employee.go
Your agent may set the model immediately:
go-modern-guidelines record --go-version 1.27
The output begins with the latest relevant pointers and features a steady identifier (ID) for every one:
... sync_waitgroup_go: Use wg.Go when spawning goroutines tracked by a sync.WaitGroup. testing_t_context: Use t.Context() when a check operate wants a context tied to the check lifetime. json_omitzero: Use omitzero on JSON-tagged bool, numeric, struct, and time fields whose zero worth needs to be omitted; maintain omitempty for empty strings, slices, and maps. ...
The brief output helps the agent discover related steering with out loading all obtainable explanations and code samples.
An agent might not acknowledge a latest Go function or know find out how to apply it as a result of the function falls outdoors its coaching knowledge. When the agent wants extra details about a tenet, it makes use of the clarify subcommand.
go-modern-guidelines clarify generic_methods
The command returns an in depth clarification and a before-and-after instance. The instance compares an older sample with its trendy alternative, serving to the agent apply the change accurately.
generic_methods:
  Since: Go 1.27
  Abstract:
    Use generic strategies as a substitute of package-level generic helper features when the operation naturally belongs to the kind itself.
  Particulars:
    Generic strategies maintain operations within the namespace of the kind that owns them. Hold package-level helpers for operations that don't naturally belong to 1 receiver kind.
  Examples:
  Earlier than:
    kind Set[T comparable] map[T]struct{}
    func Map[T comparable, U any](s Set[T], f func(T) U) []U {
      out := make([]U, 0, len(s))
      for worth := vary s {
        out = append(out, f(worth))
      }
      return out
    }
    names := Map(customers, func(person Person) string {
      return person.Title
    })
  After:
    kind Set[T comparable] map[T]struct{}
    func (s Set[T]) Map[U any](f func(T) U) []U {
      out := make([]U, 0, len(s))
      for worth := vary s {
        out = append(out, f(worth))
      }
      return out
    }
    names := customers.Map(func(person Person) string {
      return person.Title
    })
Your agent can request a number of explanations in a single command:
go-modern-guidelines clarify generic_methods atomic_types errors_as_type
What the rules cowl
The venture covers helpful language options and commonplace library additions from Go 1.0 via Go 1.27. It additionally contains the patterns dealt with by the Go modernize analyzer.
The rules assist brokers select patterns comparable to:
slices.Comprisesas a substitute of a guide search loop.minandmaxas a substitute of handwritten comparisons.cmp.Oras a substitute of a series that selects the primary nonzero worth.sync.WaitGroup.Goas a substitute of separateAdd,go, andCompletedcalls.errors.AsTypefor type-safe error matching in Go 1.26 and later.new(worth)whenever you want a pointer to a worth in Go 1.26 and later.strings.CutLastandbytes.CutLastas a substitute of LastIndex and guide slicing in Go 1.27.
These examples resolve a standard downside with generated code. An agent might know an older sample as a result of that sample seems in a big physique of present code. The supply of specific guidelines helps the agent select essentially the most present type of a given syntax.
These trendy Go expertise complement instruments comparable to go repair. Our repository helps brokers write present code from the beginning, whereas the go repair command helps replace patterns that exist already in a codebase.
Putting in the rules into your AI agent
You possibly can set up the plugin from {the marketplace} or from an area repository. Each strategies require the Go toolchain in your PATH. On first use, the mixing installs the command-line device with go set up and shops it in an area cache. It doesn’t modify your venture.
Set up the plugin from {the marketplace}
- Open a session along with your AI agent (for instance, run
claudewithin the terminal). - Add the Fashionable Go Pointers as a Claude market:
/plugin market add JetBrains/go-modern-guidelines
- Set up the plugin:
/plugin set up modern-go-guidelines
- Activate the rules:
/use-modern-go
The mixing checks the Go model in your venture and offers the AI agent with the corresponding pointers.
Set up the plugin from an area repository
Use an area repository to check the plugin earlier than publishing or updating it. The repository root should include the .*-plugin/market.json file.
- Open a terminal and run your AI coding agent.
- Add the native repository as a Claude market. Substitute the instance path with absolutely the path to your repository:
<claude|codex> plugin market add /absolute/path/to/go-modern-guidelines
- Set up the plugin from {the marketplace}:
<claude|codex> plugin set up modern-go-guidelines@goland-<claude|codex>-marketplace
- Begin or restart your AI agent in your Go venture.
- Activate the rules within the session:
/use-modern-go
The AI agent reads {the marketplace} definition out of your native repository and installs the plugin in its plugin cache. Your repository stays {the marketplace} supply.
Language releases transfer sooner than mannequin coaching cycles. Your coding agent wants a small, present supply of reality to maintain up.
Our repository of contemporary Golang expertise offers that supply, with out sending irrelevant materials to the agent. Your go.mod file units the boundary. The record subcommand reveals what applies. The clarify subcommand provides element solely when the agent wants it.
Discover the venture, set up directions, and present pointers within the Fashionable Go Pointers repository.
Blissful coding!
The GoLand staff

