Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Go to Implementation (Golang)New to Visual Studio Code? Get it now.
Go to Implementation (Golang)

Go to Implementation (Golang)

comerc

|
52 installs
| (1) | Free
Excludes mocks, tests, and other specified files.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Go to Implementation (Golang)

Test License: MIT Project status

A Visual Studio Code extension to exclude some files when using "Go to Implementation" in Go projects.

Description

This extension improves the default Go to Implementation behavior in Visual Studio Code for Go projects by filtering out some files (e.g., *_mock.go, mocks/*) from navigation results. It is ideal for projects using generators like uber-go/mock or vektra/mockery etc. Also useful for ignoring external packages (e.g., with adapters).

Key Features

  • ✅ Filters files based on customizable glob patterns (e.g., **/*_mock.go, **/mocks/**/*.go).
  • ✅ Customize mock file patterns via settings.json.
  • ✅ Displays a pick list if multiple valid implementations exist.
  • ✅ Provides an enhanced Go to Implementation with Ctrl+Alt+F12 (Cmd+Opt+F12 on Mac) while keeping the native command unchanged.

Development

  1. Clone the repository:
$ git clone https://github.com/comerc/golang-go-to-impl.git
  1. Navigate to the directory:
$ cd golang-go-to-impl
  1. Install dependencies:
$ npm install
  1. Build the project:
$ npm run compile
  1. Run the extension in debug mode (for development):
  • Open the folder in VS Code.
  • Press F5 to launch the extension host.

Manual Installation

  1. Download golang-go-to-impl-*.vsix from latest release.
  2. Open Command Palette Ctrl+Shift+P (Cmd+Shift+P on Mac).
  3. Type ">Extensions: Install from VSIX..." and select the downloaded file.

Usage

  1. Open a .go file in Visual Studio Code.
  2. Click on an interface method or function signature.
  3. Press Ctrl+Alt+F12 (Cmd+Opt+F12 on Mac) to trigger Go to Implementation.
  4. The extension will:
    • Fetch implementation locations from the language server (e.g., gopls).
    • Filter out mock files based on configured patterns.
    • Navigate to the result or show a pick list.
  5. Easy navigation back with Alt+F12 (Opt+F12 on Mac) to return to the previous location.

Configuration

Customize mock file patterns in settings.json:

{
  "golangGoToImplementation.excludePatterns": [
    "**/*_mock.go",     // Files ending with _mock.go
    "**/mock/**/*.go",  // Files in mock directories
    "**/mocks/**/*.go", // Files in mocks directories
    "**/mock_*.go",     // Files starting with mock_ followed by any characters
  ]
}

Example Custom Patterns:

{
  "golangGoToImplementation.excludePatterns": [
    "**/test/**",       // Files in test directories
    "**/testdata/**",   // Files in test directories
    "**/stubs/**/*.go", // Files in stubs directories
    "**/generated/*.go" // Auto-generated files
  ]
}

Dependencies

  • gopls: Go language server supporting Go to Implementation.

Contributing

Contributions are welcome! Here's how to get started:

  1. Fork this repository.
  2. Create a feature branch: git checkout -b new-feature.
  3. Commit your changes: git commit -am 'Add new feature'.
  4. Push to the branch: git push origin new-feature.
  5. Submit a Pull Request.

License

MIT © comerc

Issues or Suggestions?

Report bugs or request features at: https://github.com/comerc/golang-go-to-impl/issues

Keywords

Go, Golang, VSCode, Mock, Go to Implementation, gopls, Mock Generator, Interface Navigation

Notes

  • Works only for Go files (editorLangId == 'go').
  • Does not interfere with built-in commands for other languages.

Example Output

Before (Without Extension)

interfaces.go:10: func DoSomething()
→ Implementations found:
  - service.go
  - mocks/mock_service.go
  - testdata/fake_service.go

After (With Extension)

interfaces.go:10: func DoSomething()
→ Implementations found:
  - service.go

Video

Before (Without Extension)

Before

After (With Extension)

After

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft