Go Deps Navigator
A Visual Studio Code extension that provides an explorer view for Go dependencies in your workspace.
Features
- Dependency Tree View: Shows all Go dependencies in a dedicated explorer pane
- Multiple go.mod Support: Handles workspaces with multiple go.mod files
- Full Directory Navigation: Browse the complete directory structure of dependencies
- File Tree Explorer: Expand dependencies to see all files and subdirectories
- Clickable Navigation: Click on any file to open it directly in the editor
- Replace Directive Support: Handles
replace directives in go.mod files
- Local Directory Navigation: Navigate to local replacement directories
- Auto-refresh: Automatically updates when go.mod files change
- Indirect Dependencies: Shows both direct and indirect dependencies with clear labeling
- Smart Icons: Different icons for Go files, directories, markdown files, and other file types
- Visual Indicators: Distinct icons and labels for local replacements vs regular dependencies
How it works
- The extension scans your workspace for
go.mod files
- For each go.mod file, it parses the dependencies and
replace directives
- Dependencies are displayed in a tree view in the Explorer pane
- Local replacements show the local directory path instead of module cache
- Expand any dependency to browse its complete directory structure
- Navigate through folders and files just like in your regular file explorer
- Click on any file to open it directly in VS Code
- The extension automatically downloads dependencies if they're not already cached (skipped for local replacements)
Navigation Features
- Expandable Dependencies: Each dependency can be expanded to show its file structure
- Directory Browsing: Navigate through subdirectories within dependencies
- File Types: Different icons for Go files (.go), markdown files (.md), and other file types
- Sorted Display: Directories appear first, followed by files, both sorted alphabetically
- Direct File Access: Click any file to open it immediately in the editor
Replace Directive Support
The extension fully supports replace directives in your go.mod files:
Local Replacements: replace github.com/example/module => ./local-path
- Shows as
module-name → local-folder (local) in the tree
- Navigate directly to your local development directory
- Special folder icon to distinguish from regular dependencies
Remote Replacements: replace github.com/example/module => github.com/fork/module v1.2.3
- Shows the replacement target in the dependency label
- Downloads and caches the replacement module
Visual Indicators: Local replacements have distinct icons and labels for easy identification
Example go.mod with replace directives:
module myproject
go 1.19
require (
github.com/gin-gonic/gin v1.9.1
github.com/myorg/shared v1.0.0
)
replace github.com/myorg/shared => ./shared-lib
replace github.com/gin-gonic/gin => github.com/myorg/gin-fork v1.9.2
In the extension, you'll see:
github.com/gin-gonic/gin → github.com/myorg/gin-fork (v1.9.2) - remote replacement
github.com/myorg/shared → shared-lib (local) - local replacement
Requirements
- Go must be installed and available in your PATH
- The extension activates when Go files are present in your workspace
Usage
- Open a Go project with one or more
go.mod files
- The "Go Dependencies" view will appear in the Explorer pane
- Expand any go.mod file to see its dependencies
- Expand any dependency to browse its directory structure
- Navigate through folders and click on any file to open it
- Use the refresh button to manually update the dependency list
Development
To build and run the extension:
- Install dependencies:
npm install
- Compile TypeScript:
npm run compile
- Press F5 to launch a new VS Code window with the extension loaded
License
MIT
| |