Golang Implementation Lens

Show implementation count above Go interfaces with one-click navigation to interface and method implementations.
✨ Features
- 🔍 Visual CodeLens above every Go interface showing "👁️ implementations"
- 🎯 Method-level CodeLens - Each method has "→ implementations" for direct navigation
- 🔙 Goto Interface Navigate from implementation methods back to their interface declarations with "← goto interface"
- 📊 Click to navigate - Opens a quick pick with all implementations
- ⚡ Fast search using grep for instant results
- 🚫 Smart filtering - Automatically excludes mock implementations
- 🏗️ Multi-package support - Works perfectly with Go modules
- 💾 Smart detection - Intelligently finds types that implement all interface methods
📸 Screenshots
Interface with CodeLens
👁️ implementations ← Click to see all implementations
type UserRepository interface {
→ implementations ← Click to see FindByID implementations
FindByID(id string) (*User, error)
→ implementations ← Click to see Save implementations
Save(user *User) error
}
Quick Pick with Interface Implementations
┌─────────────────────────────────────────────────────┐
│ Select implementation of UserRepository │
├─────────────────────────────────────────────────────┤
│ ○ PostgresUserRepository │
│ in repository/postgres.go │
│ Implements 2 method(s) │
└─────────────────────────────────────────────────────┘
Note: Mock implementations are automatically filtered out!
Quick Pick with Method Implementations
┌─────────────────────────────────────────────────────┐
│ 3 implementation(s) of UserRepository.FindByID │
├─────────────────────────────────────────────────────┤
│ ○ PostgresUserRepository.FindByID │
│ repository/postgres.go:45 │
│ func (r *PostgresUserRepository) FindByID... │
├─────────────────────────────────────────────────────┤
│ ○ MemoryUserRepository.FindByID │
│ repository/memory.go:23 │
│ func (r *MemoryUserRepository) FindByID... │
└─────────────────────────────────────────────────────┘
Goto Interface (Reverse Navigation) ⭐ NEW
// In your implementation file
← goto interface ← Click to see which interfaces declare FindByID
func (r *PostgresUserRepository) FindByID(id string) (*User, error) {
// implementation
}
🚀 Usage
Method 1: Interface CodeLens (Full Implementation)
- Open any Go file with an interface
- Look above the
type InterfaceName interface { declaration
- Click on "👁️ implementations"
- Select the implementation from the list
- Navigate automatically to the struct declaration!
Method 2: Method CodeLens (Direct Method Navigation)
- Open any Go file with an interface
- Look at each method inside the interface
- Click on "→ implementations" next to any method
- Select the specific implementation you want
- Navigate directly to that method implementation!
Method 3: Goto Interface (Reverse Navigation) ⭐ NEW
- Open any Go file with a struct method implementation
- Look above the method declaration with receiver (e.g.,
func (r *Type) Method())
- Click on "← goto interface"
- Select the interface that declares this method
- Navigate automatically to the interface declaration!
Method 4: Command Palette
- Press
Cmd+Shift+P (Mac) or Ctrl+Shift+P (Windows/Linux)
- Type: "Go: Show Implementations", "Go: Show Method Implementations", or "Go: Goto Interface"
- Enter the interface/method name
- Select from the list
📋 Requirements
- VSCode/Cursor: 1.60.0 or higher
- Go files:
.go extension
- Project structure: Works with Go modules and any project structure
- Search tool:
grep (pre-installed on macOS/Linux, Git Bash on Windows)
⚙️ How It Works
CodeLens Provider
The extension registers a CodeLens provider that:
- Scans all Go files for
type Name interface { declarations
- Shows a clickable lens above each interface
- On click, searches for types that implement all interface methods
Search Strategy
The extension:
- Extracts all method signatures from the interface
- Searches for receiver functions matching the first method
- Validates that the type implements ALL interface methods
- Shows only types that fully implement the interface
This pattern matches Go's implicit interface implementation:
type UserRepository interface {
FindByID(id string) (*User, error)
Save(user *User) error
}
type PostgresUserRepository struct {
db *sql.DB
}
// These methods are automatically detected!
func (r *PostgresUserRepository) FindByID(id string) (*User, error) {
// implementation
}
func (r *PostgresUserRepository) Save(user *User) error {
// implementation
}
- First search: ~50-300ms (depending on project size)
- Validation: Checks all methods to ensure complete implementation
- Smart filtering: Only shows types that implement ALL interface methods
🎨 Configuration
The extension works out-of-the-box with sensible defaults, but you can customize the filtering behavior to match your project structure.
🚫 Filtering Configuration
You can configure which folders, files, and types to exclude from the implementation search. This is useful for filtering out mocks, generated code, test files, and vendor dependencies.
Settings
Open VS Code/Cursor settings (Cmd+, or Ctrl+,) and search for "Golang Implementation Lens" to configure:
golangImplementationLens.excludedFolders
- Array of folder names to exclude from search
- Default:
["mocks", "mock", "testdata", "vendor"]
- Example: Add custom folders like
["mocks", "mock", "testdata", "vendor", "generated", "third_party"]
golangImplementationLens.excludedFilePatterns
- Array of file name patterns to exclude
- Default:
["_mock.go", "mock_", ".pb.go", "_test.go"]
- Example: Add proto files like
["_mock.go", "mock_", ".pb.go", "_test.go", ".gen.go"]
golangImplementationLens.excludedTypePatterns
- Array of type name patterns to exclude
- Default:
["Mock", "mock", "Stub", "Fake"]
- Example: Add custom patterns like
["Mock", "mock", "Stub", "Fake", "Test", "Dummy"]
Configuration Example
Add to your settings.json:
{
"golangImplementationLens.excludedFolders": [
"mocks",
"mock",
"testdata",
"vendor",
"generated",
"proto"
],
"golangImplementationLens.excludedFilePatterns": [
"_mock.go",
"mock_",
".pb.go",
"_test.go",
".gen.go"
],
"golangImplementationLens.excludedTypePatterns": [
"Mock",
"mock",
"Stub",
"Fake",
"Test"
]
}
How Filtering Works
The extension checks each potential implementation against your configuration:
- Folder Check: Excludes if file path contains any excluded folder name
- File Pattern Check: Excludes if file name contains any excluded pattern
- Type Pattern Check: Excludes if type name contains any excluded pattern
- Underscore Check: Always excludes types starting with
_ (test helpers)
🔧 Commands
| Command |
Description |
Go: Show Implementations |
Manually search for interface implementations |
Go: Show Method Implementations |
Manually search for method implementations |
Go: Goto Interface |
Navigate from method implementation to interface declaration |
Go: Clear Implementation Lens Cache |
Clear cached search results |
🐛 Troubleshooting
CodeLens not showing?
- Make sure you're viewing a
.go file
- Check that the file contains
type Name interface { declarations
- Reload window:
Cmd+Shift+P → "Reload Window"
"No implementations found"?
- Verify the implementation exists
- Check that all interface methods are implemented
- Ensure the receiver functions follow Go conventions:
func (r *Type) Method()
- Try clearing cache:
Cmd+Shift+P → "Go: Clear Implementation Lens Cache"
Extension not loading?
- Check VSCode/Cursor version (must be 1.60+)
- View Extension Host logs:
Cmd+Shift+P → "Developer: Show Logs" → "Extension Host"
- Look for errors related to
golang-implementation-lens
📦 Installation
From Marketplace (Coming Soon)
- Open Extensions:
Cmd+Shift+X
- Search: "Golang Implementation Lens"
- Click "Install"
Manual Installation
- Download
.vsix file from releases
- Open Extensions:
Cmd+Shift+X
- Click
... → "Install from VSIX..."
- Select downloaded file
From Source
cd ~/.cursor/extensions/
git clone https://github.com/fabioods/golang-implementation-lens.git
cd golang-implementation-lens
npm install
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Development Setup
# Clone the repository
git clone https://github.com/fabioods/golang-implementation-lens.git
cd golang-implementation-lens
# Install dependencies (if any)
npm install
# Open in VSCode/Cursor
code .
# Press F5 to launch Extension Development Host
📝 Changelog
See CHANGELOG.md for release history.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Built for the Go community
- Inspired by VS Code's native implementation lens
- Special thanks to all contributors
🔗 Links
💡 Tips & Tricks
Keyboard Shortcut
Add a custom keybinding for quick access:
{
"key": "cmd+shift+i",
"command": "golang-implementation-lens.showImplementations"
}
Works with Interfaces
The extension understands Go's implicit interface implementation, so you don't need any special syntax or annotations!
🌟 Star History
If you find this extension useful, please consider giving it a ⭐ on GitHub!
Made with ❤️ for the Go community