GoLand-style interface stub generation: put the cursor on a type, pick an interface (current package, workspace, dependencies, stdlib) and the missing methods are generated for you.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
GoLand-style Implement Interface for VS Code. Put the cursor on a Go type
(usually a struct), run the command, pick an interface, and the missing method
stubs are generated for you.
Usage
Place the cursor on a type declaration, e.g. type Server struct { ... }.
Run Go: Implement Interface (Generate Stubs) from the Command Palette
(Cmd+Shift+P), press Ctrl+Alt+Shift+I, use the editor context menu, or
pick the lightbulb code action ("Implement interface for 'Server'…")
that appears on type declarations.
Type to search. Suggestions are grouped, in order:
current package — interfaces of the package you are in (including unexported ones)
workspace — exported interfaces elsewhere in your workspace
dependencies — exported interfaces from your module dependencies (go list -m all)
standard library — exported interfaces from the Go standard library (plus the built-in error)
Pick one. The missing methods are inserted and any required imports are added.
For a generic interface (e.g. Lesser[T any]) you are prompted for the
type arguments (e.g. int); signatures are generated with those types
substituted.
Behavior
Receiver: if the type already has methods, their receiver name and
pointer/value style is reused. Otherwise a pointer receiver named after the
first letter of the type is used (func (s *Server)).
Only missing methods are generated — methods that already exist (directly
or promoted through embedding) are skipped; existing methods with a
conflicting signature are reported.
Placement: stubs are inserted right after the type declaration, or after
the type's last method in the file (configurable to end-of-file).
Works on unsaved buffers; imports are added automatically; output is gofmt-formatted.
Requirements
The Go toolchain (go) must be installed. On first activation the extension
compiles its small Go helper with go build (this may download
golang.org/x/tools into your module cache once).
The first interface listing in a project scans your dependencies and the
standard library; results are cached (per module version / Go version), so
subsequent runs are fast. Cache entries unused for 30 days are pruned
automatically.
Settings
Setting
Default
Description
goImplementInterface.goBinary
go
Path to the go binary.
goImplementInterface.methodBody
panic-todo
panic-todo, panic, or zero (return zero values).
goImplementInterface.insertionPoint
afterType
afterType or endOfFile.
goImplementInterface.scanDependencies
true
Include interfaces from module dependencies.
Limitations
Type arguments for generic interfaces must be resolvable in the current file
(add the import first if the argument comes from another package).
Constraint-only interfaces (containing type unions like ~int | ~float64)
cannot be implemented — they have no method set.
Packages that cannot be built for your platform (e.g. syscall/js) may fail
to load when picked.
Development
npm install
npm run compile # type-check + emit dist/
npm run package # build the .vsix
Press F5 in VS Code to launch an Extension Development Host.