Go
Open a folder with a go.mod and Ferris IDEA starts gopls for code insight, offers go test as a
run configuration with a result tree, and debugs programs and tests with Delve. Go support is
Works.
Before you start
Section titled “Before you start”-
Go, with
goon thePATH. -
gopls:
-
Delve for debugging. Ferris IDEA looks for
dlvinFERRIS_IDEA_DLV, on thePATH, in$GOBIN,$GOPATH/binand~/go/bin: -
Developer Mode on macOS for debugging:
sudo DevToolsSecurity -enable.
What you get
Section titled “What you get”Completion, navigation, find usages, rename, hierarchies, diagnostics and quick fixes come from
gopls, with parameter-name hints turned on. Reformat Code
(⌥⌘L) asks gopls, which formats the way gofmt does.
Run and test
Section titled “Run and test”-
Open the project. The run list shows go test (
go test -json ./...) under “Detected from build files”. -
In
*_test.gofiles the gutter shows ▶ on everyTestXxxfunction. -
Run › Run Current File (⌃⇧R):
Caret in Command a file of package maingo run <file>a test function go test -json -run '^TestName$' <package>elsewhere in a _test.gofilego test -json <package> -
The JSON output of
go testfills the result tree; see Run tests.
- Set a breakpoint on a line with a statement (⌘F8).
- Run › Debug Current File (⌃⇧D) on a
package mainfile, or with the caret in a test. Delve builds and starts the program. - Step and evaluate as in Debug a program. An exception breakpoint for Go with “uncaught” stops on a panic that nothing recovers, with its message. Delve cannot stop on every panic, so “caught” only gets a note in the debug console and the session goes on.
To debug a running Go program, use Attach to Process with its process id, or a headless Delve server on the loopback interface.
When it does not work
Section titled “When it does not work”- “Cannot debug Go: Delve is not installed …”: run the
go installcommand above, or setFERRIS_IDEA_DLVto thedlvprogram. - A breakpoint stays hollow with “could not find statement at …”: the line has no statement, for example a closing brace; move it to a line with code.
- “Cannot debug: this Mac needs Developer Mode”: run
sudo DevToolsSecurity -enableonce.
Shortcuts
Section titled “Shortcuts”| Action | Shortcut |
|---|---|
| Code › Reformat Code | ⌥⌘LCtrlAltL |
| Run › Debug Current File | ⌃⇧Dno shortcut |
| Run › Run Current File | ⌃⇧RCtrlShiftF10 |
| Run › Toggle Line Breakpoint | ⌘F8CtrlF8 |
For agents
Section titled “For agents”debug_start takes go_test to debug one test.
debug_attachAttach a debugger to a running program: native (lldb-dap), python (debugpy), node (js-debug), java (JDWP) or go (Delve), bypidor debugport.debug_startStart a debug session: native programs with lldb-dap, Go with Delve (go_testfor tests), Python with debugpy, Node.js/TypeScript scripts or annpm_scriptwith js-debug, or a Kotlinmain_class.format_fileFormat a workspace file (or arange) as Reformat Code does.run_commandRun one program with arguments in the workspace (no shell).run_markersThe run markers (gutter ▶) of a file with 1-based line and the run configuration each starts: Java/Kotlinmainand JUnit tests (single method via Maven or Gradle), Vitest/Jestdescribe/it/test, pytest, Go and Rust tests, and themainof Go programs, Rust binaries and examples, and Python scripts (kindmain).
No tool matches. Try fewer words, or .