A Visual Studio Code extension that provides advanced Go development features that extend beyond the official VS Code Go extension.
Go Extras enhances the Go development experience in VS Code by adding powerful features not found in the standard toolset. This extension will grow over time to include various capabilities that make Go development more productive and insightful. The initial release focuses on improving symbol reference analysis with intelligent filtering options.
You can install Go Extras directly from the Visual Studio Code Marketplace:
- Open VS Code
- Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
- Search for "Go Extras"
- Click Install
Alternatively, you can install the extension using the VS Code Quick Open (Ctrl+P / Cmd+P):
ext install shivamkumar.go-extras
- Dedicated Panel View: Displays references in a structured tree view within the VS Code panel (
Go Extras: Filtered References
). - Reference Classification: Leverages the Go Language Server (
gopls
via thegolang.go
extension) to classify references as:- Read: Symbol is being read (e.g., used in an expression).
- Write: Symbol is being written to (e.g., assignment, declaration).
- Text: Symbol appears in comments or strings (classification may vary based on
gopls
behavior).
- Interactive Filtering:
- Checkboxes: Quickly toggle Read/Write/Text classifications to filter the displayed references.
- Tree View Selection: Click on files or directories within the tree to narrow down the references shown in the Peek View.
- Path Compression: Directory paths in the tree view are compressed (e.g.,
src/app/components/
instead of nested nodes) for better readability. - Peek View Integration: Filter selections instantly update VS Code's native Peek References view (
editor.action.showReferences
). - Direct Navigation: Clicking on a specific reference line (e.g.,
Line 10:5
) in the tree view navigates directly to that location in the editor.
You can activate the Filtered References feature in several ways when your cursor is on a Go symbol:
- Command Palette: Open the Command Palette (
Ctrl+Shift+P
orCmd+Shift+P
) and search forGo Extras: Filtered References
. - Context Menu: Right-click on the symbol in a Go file and select
Go Extras: Filtered References
. - Keyboard Shortcut: Press
Alt+Shift+R
(configurable in VS Code keyboard shortcuts).
- Place your cursor on a Go symbol (variable, function, type, etc.) in your code.
- Activate the feature using one of the methods listed above.
- The Go Extras: Filtered References panel will open (usually in the bottom panel area).
- The panel displays:
- Checkboxes for
Read
,Write
, andText
filters (initially all checked). - A tree view grouping references by file and directory.
- Checkboxes for
- Simultaneously, VS Code's Peek View will appear, showing all found references.
- Filtering:
- Uncheck/check the
Read
,Write
,Text
boxes in the panel to instantly filter the locations shown in the Peek View. The tree view itself currently shows all references but may be updated in the future. - Clicking a file or directory in the panel's tree view will filter the Peek View to show only references within that selection.
- Clicking a specific reference line (e.g.,
Line 15:3
) in the tree view will close the Peek View and navigate directly to that line in the editor.
- Uncheck/check the
- Visual Studio Code.
- Go Extension: The official
golang.go
extension must be installed and enabled, as Go Extras relies on it for finding and classifying references via the Go Language Server (gopls
). - Semantic Highlighting: This extension requires semantic highlighting to be enabled in gopls. To enable it:
- Open VS Code Command Palette (
Ctrl+Shift+P
/Cmd+Shift+P
) - Search for "Preferences: Open User Settings (JSON)" and select it.
- Add the following configuration to your
settings.json
file:"gopls": { "ui.semanticTokens": true }
- Save the file and restart VS Code for changes to take effect.
- Open VS Code Command Palette (
- Node.js (LTS version recommended)
- npm (comes with Node.js)
- Visual Studio Code for testing
- Clone the repository:
git clone https://github.com/ShivamKumar2002/go-extras.git
cd go-extras
- Install dependencies:
npm install
- Compile (Development):
npm run compile
This runs type checking, linting, and builds the extension using esbuild.
- Watch Mode:
npm run watch
This starts a development mode that automatically rebuilds when files change. It runs both esbuild and TypeScript type checking in watch mode.
- Package for Production:
npm run package
This creates a production build of the extension, optimized and ready for distribution.
- Type Checking:
npm run check-types
Runs the TypeScript compiler to check for type errors without emitting files.
- Linting:
npm run lint
Runs ESLint to check for code style issues and potential bugs.
- Run Tests:
npm test
This runs the test suite using VS Code's testing infrastructure.
- Compile Tests Only:
npm run compile-tests
- Open the repository in VS Code
- Press F5 to start debugging
- This will launch a new VS Code Extension Development Host window where you can test the extension
The extension is published to the VS Code Marketplace using:
vsce package
vsce publish
Note: You'll need to have @vscode/vsce
installed globally and be logged in with appropriate publisher rights.
This extension does not currently contribute any specific settings.
- Reference classification accuracy depends entirely on the underlying
gopls
results provided by thegolang.go
extension.
Please report any bugs or unexpected behavior by opening an issue on the project's GitHub repository.
See the CHANGELOG.md file for details on changes in each version.
Contributions are welcome and appreciated! Here's how you can contribute:
- Report Issues: Found a bug or have a feature request? Open an issue.
- Submit Pull Requests: Have a fix or new feature to contribute? Submit a pull request.
- Improve Documentation: Help improve documentation by fixing errors or adding examples.
Please ensure your code follows the project's coding standards and includes appropriate tests.
- memory-bank/: This directory is automatically generated and managed by the Roo Code/Cline.
This extension is licensed under the MIT License.
Copyright (c) 2025 Shivam Kumar