go-modern-guidelines  by JetBrains

Modern Go idioms for AI code generation

Created 4 months ago
606 stars

Top 53.9% on SourcePulse

GitHubView on GitHub
Project Summary

Modern Go Guidelines provides explicit instructions for AI code agents to generate contemporary Go code, addressing the prevalent issue of outdated patterns caused by training data lag and frequency bias. It benefits developers by ensuring new code adheres to modern Go idioms and standard library features, thereby reducing the need for subsequent refactoring and promoting maintainability.

How It Works

These guidelines provide an explicit reference for AI code agents, enabling them to generate modern Go code by leveraging language features and standard library additions available up to the project's detected Go version (from go.mod). This approach directly combats the common issue of AI models producing outdated code due to training data lag and frequency bias. Instead of older, less idiomatic patterns, agents are guided to use modern equivalents such as max(a, b) over if-else blocks, slices.Contains instead of manual loops, cmp.Or for chained nil checks, new(42) for obtaining pointers to values, and errors.AsType[T](err) for type-safe error matching. This explicit instruction ensures new code aligns with contemporary Go best practices and the direction of the Go team's modernize analyzer.

Quick Start & Requirements

  • Junie: Guidelines are included out-of-the-box starting with version 2xx.620.xx. Enable via Settings → Tools → Junie → Project Settings → Go → Provide modern Go guidelines.
  • Claude Code: Install as a plugin:
    1. Add marketplace: /plugin marketplace add JetBrains/go-modern-guidelines
    2. Install plugin: /plugin install modern-go-guidelines
    3. Activate with /use-modern-go command at the start of a session.
  • Prerequisites: Compatible Junie or Claude Code version. The agent detects the project's Go version from go.mod.

Highlighted Details

  • Covers Go language features from version 1.0 through 1.26.
  • Aligns with the goals of the Go team's modernize analyzer for new code generation.
  • Explicitly teaches agents modern idioms like slices.Contains and errors.AsType.

Maintenance & Community

No specific details on contributors, sponsorships, or community links (Discord/Slack) were found in the provided text.

Licensing & Compatibility

No license information was explicitly stated in the provided text.

Limitations & Caveats

Effectiveness relies on the AI agent's correct interpretation and application of these guidelines. Compatibility is dependent on the specific versions of Junie or Claude Code used.

Health Check
Last Commit

3 days ago

Responsiveness

Inactive

Pull Requests (30d)
3
Issues (30d)
1
Star History
129 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.