Write Modern Go Code With Junie and Claude Code
Go developers can now confidently write modern Go code using the AI agents Junie and Claude Code. We at JetBrains have just released a new plugin with guidelines for AI agents that ensure they use the latest features and follow best Go practices compatible with your current version of Go, as specified in go.mod. You can find the relevant GitHub repository at go-modern-guidelines.
Why do you need it?
With two major releases every year, Go is one of the more frequently updated languages. Yet we’ve found that all AI agents – Junie and Claude Code included – tend to generate obsolete Go code.
The Go team also pointed to that problem in one of their articles: “During the frenzied adoption of LLM coding assistants, we became aware that such tools tended – unsurprisingly – to produce Go code in a style similar to the mass of Go code used during training, even when there were newer, better ways to express the same idea.”
As an example, here’s a sample code snippet of how an agent used a manual loop to find an element in the slice:
// HasAccess checks if the user's role has access to protected resources.
func HasAccess(role string) bool {
for _, allowed := range allowedRoles {
if role == allowed {
return true
}
}
return false
}
There are two main reasons why agents would favor obsolete architecture where cleaner and more idiomatic solutions are available:
- Data cutoff: Even the most current AI models are trained on time-bound datasets that have a “cutoff” date (for example, for Claude Opus 4.6, that’s May 2025). They will not recognize or suggest features that were introduced after that point, such as those found in the Go 1.26 release.
- Frequency bias: AI models are primarily trained on open-source codebases that may not be readily updated. It’s natural that such datasets will feature more “old” code than “new”, and since AI models favor alternatives that are more frequent, they will suggest obsolete code as a result.
Just like the Go team, we at GoLand, strive to keep the Go ecosystem modern and idiomatic. So to mitigate the effect of AI agents contributing to this issue, we’ve created a plugin with a set of guidelines for Junie and Claude Code, that helps them generate modern Go code. The plugin automatically recognizes the current version of your Go code (specified in go.mod) and instructs the agent to use corresponding features, such as new(val) instead of x := val; &x or errors.AsType[T](err) instead of errors.As(err, &target) (both introduced in Go 1.26), as well as stdlib additions available up to and including that version.
Here’s the same code sample from before with our guidelines applied, where the agent actually uses the modern slices.Contains() method introduced in Go 1.21.
var allowedRoles = []string{"admin", "moderator", "editor"}
// HasAccess checks if the user's role has access to protected resources.
func HasAccess(role string) bool {
return slices.Contains(allowedRoles, role)
}
How to enable
In Junie
For Junie version 2xx.620.xx or higher, you don’t have to do anything – these guidelines will be applied right out of the box.
If you’re running an older version, go to Settings → Plugins → Installed, find Junie, and then click Update.
If, for some reason, you want to disable these settings, you can do so in Settings → Tools → Junie → Project Settings → Go. The Provide modern Go guidelines option is enabled by default, so untick the box.
In Claude Code
To use these guidelines in Claude Code, run the following commands inside a Claude Code session to install it.
Add this repository as a marketplace:
/plugin marketplace add JetBrains/go-modern-guidelines
Install the plugin:
/plugin install modern-go-guidelines
To activate it, run the following command at the start of a session:
/use-modern-go
Claude Code will then detect the Go version from go.mod and instruct the agent to use modern features compatible with that version.
> /use-modern-go This project is using Go 1.24, so I'll stick to modern Go best practices and freely use language features up to and including this version. If you'd prefer a different target version, just let me know.
After this, any Go code that the agent writes will follow the guidelines.
Happy coding!
The GoLand team