GitHub Copilot in GoLand: the best configuration to write Go faster

2026-04-10

post-thumb

Contents

Writing Go in GoLand is already a solid experience. Adding GitHub Copilot on top makes the combo almost unfairly good. But there’s a catch: generic Copilot tends to suggest code that isn’t idiomatic Go (interface abuse, swallowed errors, generics where they don’t belong). In this guide I’ll show you the configuration I use to make Copilot look like a gopher, and the shortcuts that save the most time day to day.

If you also work on front-end, check out my other guide: GitHub Copilot in WebStorm: the best configuration to supercharge your day.


Before you start: requirements

To follow this tutorial, you’ll need:

  • GoLand 2024.3.6 or later (I recommend the latest build, which resolved the Tab conflict)
  • Go 1.22 or later installed and configured in GoLand
  • gopls up to date (GoLand installs it automatically, but worth verifying)
  • A GitHub account with an active Copilot license (Individual, Business, or Enterprise)
  • Stable internet connection

If you’re still on an old version of GoLand, update first. Older versions have a conflict between Copilot and Full Line Code Completion fighting over the Tab key.


Step 1: install the official plugin

  1. Open GoLand
  2. Go to Settings (Cmd + , on Mac / Ctrl + Alt + S on Windows/Linux)
  3. Navigate to Plugins
  4. Click the Marketplace tab
  5. Type GitHub Copilot in the search
  6. Click Install on the official GitHub plugin
  7. Next, also install GitHub Copilot Chat (it comes separately in some versions)
  8. Restart GoLand when prompted

On GoLand 2025+, the GitHub Copilot plugin already includes the chat. If you only see a single plugin called GitHub Copilot, that’s the one with everything bundled.


Step 2: log in with your GitHub account

After restart, the Copilot icon appears in the bottom right bar.

  1. Click the Copilot icon
  2. Choose Login to GitHub
  3. Copy the device code that appears
  4. GoLand opens your browser at github.com/login/device
  5. Paste the code and authorize access
  6. Come back to GoLand and wait for confirmation

When the icon turns green, Copilot is ready to use.


Step 3: resolve the conflict with Full Line Code Completion

This is the most important step for anyone who wants Tab working without surprises. GoLand has a native Full Line Code Completion that also takes Tab and competes with Copilot. If you leave both on, you never know which one will be accepted.

  1. Settings > Editor > General > Inline Completion
  2. Uncheck Enable local full line completion suggestions
  3. Apply and close

Option B: keep both with separate shortcuts

  1. Settings > Keymap
  2. Look for Insert Inline Completion
  3. Remap GoLand’s one to a non-conflicting shortcut, like Cmd + Shift + ] (Mac) / Ctrl + Shift + ] (Windows/Linux)
  4. Leave Apply completions to Editor (Copilot’s) on Tab

In practice, for Go I prefer option A: Copilot knows more about the project context as a whole, and Full Line ends up adding very little.


Step 4: fine-tuning the plugin

Go to Settings > Tools > GitHub Copilot > Completions and adjust:

OptionRecommended valueWhy
Show completions automaticallyEnabledSuggests as you type
Automatically check for updatesEnabledKeeps the plugin up to date
Enable CopilotEnabledPer-language toggles are below

In the Languages section, my recommendation for day-to-day Go work:

  • Enabled: Go, Go Module, Go Sum, Go Template, YAML, TOML, Markdown, Dockerfile, SQL, Shell, JSON, Protobuf
  • Disabled: auto-generated files (*_gen.go, *.pb.go, mock_*.go): Copilot only gets in the way here

If you use Bazel or Buf a lot, also enable .bazel, .bzl, and buf.yaml files.


Step 5: enable Copilot Chat and Agent Mode

Open chat with Ctrl + Shift + C or via the right sidebar (Copilot icon).

The three available modes:

  • Ask: answers questions, explains Go code, teaches idiomatic patterns
  • Edit: edits specific files you point to
  • Agent: handles whole tasks (it picks the files and executes)

To enable Agent Mode:

  1. Settings > Tools > GitHub Copilot > Chat
  2. Check Enable Agent Mode
  3. Check Enable Agent Skills (preview, but well worth it)
  4. Choose the default model (for Go I recommend Claude Sonnet for refactor quality and GPT for speed on smaller functions)

Step 6: idiomatic custom instructions for Go

This is the secret to stop Copilot from suggesting JavaScript disguised as Go. Custom instructions are rules Copilot reads before every response.

Configuring it for the project

  1. In your project root, create the .github/ folder (if it doesn’t exist)
  2. Inside it, create the copilot-instructions.md file
  3. Paste something like this:
# Copilot Instructions

This is a Go 1.22+ service exposing an HTTP API.

## Stack
- Go 1.22 (standard library preferred whenever possible)
- Router: net/http with the new ServeMux (no external frameworks)
- Database: PostgreSQL via pgx/v5 (no ORM)
- Logging: log/slog structured in JSON
- Tests: standard testing + testify for assertions

## Required idiomatic patterns
- Never swallow errors: always return or log them with context
- Use errors.Is / errors.As, never compare errors with ==
- Never use panic in production code, only in init or main
- Pointer receivers only when you need to mutate or the struct is large
- Functions that return an error must return (T, error), never the other way around
- Never name variables with generic err when there's more than one error in scope
- Use context.Context as the first parameter in any function that touches I/O

## Tests
- Always use table-driven tests
- Subtests via t.Run with descriptive names
- Use t.Helper() in test helper functions
- Use t.Cleanup instead of defer when appropriate
- Mocks only for external I/O interfaces, never for internal logic

## Concurrency
- Never create goroutines without a clear termination plan (context or WaitGroup)
- Buffered channels only with a clear justification
- Protect shared state with sync.Mutex, not channels if it's a simple lock
- Prefer errgroup.Group for fan-out with errors

## Never do
- Never use init() for business logic
- Never use mutable global variables
- Never return nil for a slice or map when the caller expects to iterate (return empty)
- Never ignore the return of Close() on files and connections

Save it, restart the chat, and you’ll feel the difference on the first suggestion.

Configuring it globally

For rules that apply to all Go projects:

  1. Settings > Tools > GitHub Copilot > Customizations
  2. In the Global Custom Instructions section, paste a smaller set of rules
  3. Apply

AGENTS.md and CLAUDE.md

Starting in 2026.2, Copilot also reads nested AGENTS.md and CLAUDE.md files. If you’re already using Claude Code, reuse the same file: Settings > Tools > GitHub Copilot > Customizations > Enable nested AGENTS.md and CLAUDE.md.


Essential shortcuts (the ones I use every day)

Inline suggestions

ActionMacWindows/Linux
Accept full suggestionTabTab
Dismiss suggestionEscEsc
Accept line by lineShift + Option + →Shift + Alt + →
Next suggestionShift + Option + ]Shift + Alt + ]
Previous suggestionShift + Option + [Shift + Alt + [
Trigger suggestion manuallyShift + Option + \Shift + Alt + \
Open suggestions panel (10 options)Cmd + Shift + A > Open CopilotCtrl + Shift + A > Open Copilot

Important for ABNT2 keyboard users: the official Copilot defaults are Option + ], Option + [, and Option + \, but on Brazilian keyboards those combinations produce typographic characters («, », and others) and never reach Copilot. The fix is to add Shift to the combo (making it Shift + Option + ...), which is what I used in the table above. On a US keyboard, you can use the defaults without the extra Shift.

Inline chat (the most powerful one day-to-day for Go)

ActionMacWindows/Linux
Open inline chat at cursorCtrl + Shift + ICtrl + Shift + G
Run promptEnterEnter
CancelEscEsc

With inline chat you select a function, hit Ctrl + Shift + I, type “write table-driven tests for this function” and Copilot generates straight into the test file.

Full chat

ActionMacWindows/Linux
Open chat windowCtrl + Shift + CCtrl + Shift + C
New conversationCmd + N inside chatCtrl + N inside chat
Focus input fieldCmd + LCtrl + L
Attach file to context#filename.goSame

Custom shortcuts for Go

In Settings > Keymap, search for copilot and you’ll see the plugin only exposes a handful of bindable actions (copilot.chat.show, copilot.chat.inline, copilot.openCopilot, copilot.applyInlays, copilot.cycleNextInlays, copilot.cyclePrevInlays, and copilot.requestCompletions). Features like “explain”, “fix”, “generate tests” aren’t plugin actions: they’re slash commands you type inside the chat (see the next section).

What I keep in my keymap:

Plugin actionCustom shortcut
copilot.chat.show (open chat window)Cmd + Shift + K
copilot.chat.inline (open inline chat at cursor)Cmd + Shift + I
copilot.openCopilot (Copilot tool window)Ctrl + Option + \

If any shortcut conflicts, Keymap will warn you. Cmd + Shift + K normally opens Push… in Git in GoLand: I prefer triggering Push via the menu, so I free that key for Copilot. If you use Push via shortcut, pick another combo (like Cmd + Alt + K).

Once the chat is open, slash commands handle the rest:

  • /explain explains the selected function
  • /fix fixes errors reported by gopls
  • /tests generates table-driven tests
  • /doc generates a godoc comment
  • /simplify proposes a more idiomatic version

Tricks that multiply productivity

Godoc comments become complete prompts

Write a descriptive godoc above the function and Copilot implements based on it:

// FetchActivePosts returns posts published in the last 30 days,
// sorted by publication date descending, limited to 10.
// Returns an error if the database is unavailable or if the query fails.
// The context is used for cancellation.
func (r *PostsRepository) FetchActivePosts(ctx context.Context) ([]Post, error) {
    // Copilot fills in here following the rest of the repository's pattern
}

The more specific the godoc, the better the suggestion. Adding the names of relevant files to the comment helps even more.

Table-driven tests with a single command

Select the function, hit Ctrl + Shift + I, and type:

write table-driven tests for this function, covering the happy path, database error, cancelled context, and empty slice. Use testify/require in the assertions.

Copilot generates the full _test.go file, with t.Run and named subtests already in place.

Error refactor with Agent Mode

If the project still uses fmt.Errorf("%v") and you want to migrate to %w + errors.Is, open chat in Agent Mode and ask:

Refactor all error wrappers in the internal/service package to use %w and replace == comparisons with errors.Is. Keep the tests passing.

You review the changes file by file before accepting.

Use # to contextualize the chat

In chat, type #internal/repository/posts.go and #internal/service/posts.go to load the files as context. Saves you from pasting code.

Slash commands inside chat

  • /tests: generates tests for the selected code
  • /doc: generates a godoc comment
  • /fix: fixes errors reported by gopls
  • /explain: explains the selected code
  • /simplify: proposes a more idiomatic version

For Go, /simplify is gold: it often proposes versions that remove unnecessary loops, take advantage of slices from the stdlib, and trim code without losing readability.

Mock and stub generation

If you use interfaces for I/O, select the interface, open inline chat, and ask:

generate a mock for this interface using testify/mock, in the file mocks/mock_repository.go

It respects the custom instructions and generates something consistent with the rest of the project.

Optional integration with gopls via MCP

If you want Copilot to use your project’s gopls as the source of truth (go to definition, coverage, go test, go mod tidy), you can set up an MCP server like mcp-gopls. Copilot will consult Go’s LSP before suggesting, which drastically reduces hallucination on large projects. It’s advanced, but worth the learning curve if you’re working on a Go monorepo.


Fine-tuning by project type

Microservices with net/http

  • Explain in your custom instructions whether you use the new ServeMux or gorilla/chi
  • Mention the middleware pattern (func(http.Handler) http.Handler)
  • Clarify if you have typed context keys or bare strings

gRPC / Protobuf

  • Disable Copilot in .pb.go files (they’re generated, any suggestion breaks the generator)
  • Keep it enabled on .proto if you write contracts
  • Mention in custom instructions which generator you use (protoc, buf)

CLI (Cobra / urfave/cli)

  • State which library you’re using
  • Mention if there’s a subcommand convention
  • Make the error handling pattern explicit (usually run returns error)

Projects with sqlc or GORM

  • Important to flag in custom instructions which approach you use
  • If it’s sqlc, list the files where queries live
  • If it’s GORM, mention which version

Common issues and solutions

Tab doesn’t accept suggestions

Full Line Code Completion fighting. Go back to Step 3 and apply one of the two solutions.

Non-idiomatic suggestions

Custom instructions are probably empty or too generic. Review Step 6 and detail the idiomatic patterns you use.

Copilot slow in a monorepo

  1. Open just the service folder you’re working on, not the entire monorepo
  2. In Settings > Tools > GitHub Copilot > Completions, uncheck Show completions automatically and trigger on demand with Shift + Option + \ (Mac) / Shift + Alt + \ (Windows/Linux)
  3. Check that gopls isn’t indexing too much (see Help > Activity Monitor)

Red Copilot icon

  1. Click it to see the error
  2. Not signed in: log in again
  3. Network error: check proxy in Settings > Appearance & Behavior > System Settings > HTTP Proxy
  4. Quota exceeded: you hit the monthly limit

Chat doesn’t open

Install the GitHub Copilot Chat plugin separately (some versions still come separated).

Copilot suggesting interface{} or any too much

Add to your custom instructions: “Avoid any and interface{} except when there’s really no known type. Prefer concrete types or typed generics.”


Final checklist

  • GitHub Copilot plugin installed and up to date
  • GitHub Copilot Chat plugin installed
  • Logged in with the correct GitHub account
  • Full Line Code Completion disabled (or remapped)
  • Copilot enabled for your Go project’s languages
  • Agent Mode enabled in Settings
  • .github/copilot-instructions.md file created with idiomatic rules
  • Custom shortcuts configured in Keymap
  • Green icon in the bottom bar
  • gopls up to date and running without errors

With this setup locked in, Copilot stops being a generic autocompleter and becomes a pair programmer that understands Go. Within a week of using it, you’ll be writing godocs that generate entire functions and using inline chat to generate table-driven tests without taking your hands off the keyboard.