A Visual Studio Code extension that displays the disk size of Go module dependencies in go.mod files.
- 📦 Package Size Display: View the disk size of each dependency
- 🎯 Two Display Modes:
- Hover Mode: Shows size when you hover over a package (default)
- Inlay Mode: Displays sizes inline as hints
- ⚡ Smart Caching: Caches results to avoid repeated calculations
- 🎨 Customizable: Configure display units and cache duration
- 🚀 Lightweight: Runs independently without affecting gopls performance
Simply hover over any require line in your go.mod file:
require (
github.com/gin-gonic/gin v1.9.1 // Hover to see size
github.com/pkg/errors v0.9.1 // Hover to see size
)You'll see a popup showing:
- Package name and version
- Total size
- Number of files
- Local path
Enable inlay hints in settings to see sizes inline:
require (
github.com/gin-gonic/gin v1.9.1 // 2.3 MB
github.com/pkg/errors v0.9.1 // 156 KB
)Open VS Code settings and search for "Go Mod Size Viewer":
{
// Enable/disable the extension
"gomodSizeViewer.enabled": true,
// Display mode: "hover" or "inlay"
"gomodSizeViewer.displayMode": "hover",
// Cache duration in seconds (default: 1 hour)
"gomodSizeViewer.cacheDuration": 3600,
// Size unit: "auto", "KB", "MB", or "GB"
"gomodSizeViewer.unit": "auto"
}- Go Mod Size Viewer: Clear Cache - Clear all cached size data
- Go Mod Size Viewer: Refresh - Recalculate sizes for current file
Access commands via Command Palette (Cmd/Ctrl + Shift + P)
- Visual Studio Code 1.80.0 or higher
- Go modules must be downloaded to
$GOPATH/pkg/mod - For Unix/Linux/Mac: Works best with
duandfindcommands available
- Parses
requirestatements ingo.mod - Locates packages in
$GOPATH/pkg/moddirectory - Calculates directory size using:
- Native
ducommand on Unix/Linux/Mac (fast) - Recursive file traversal on Windows (cross-platform)
- Native
- Caches results to improve performance
- First calculation for each package may take a few seconds
- Results are cached for the configured duration (default: 1 hour)
- Calculations run asynchronously without blocking the editor
- Independent from gopls - doesn't affect Go language features
- Only shows sizes for already downloaded packages
- Requires packages to exist in
$GOPATH/pkg/mod - May be slower on network file systems
- Windows: Uses recursive traversal (slower than Unix
ducommand)
Size not showing?
- Ensure the package is downloaded:
go mod download - Check that
$GOPATHis set correctly - Verify the package exists in
$GOPATH/pkg/mod
Slow performance?
- Increase cache duration in settings
- Switch to hover mode if using inlay mode
- Clear cache if it becomes stale
Issues and pull requests are welcome on GitHub.
MIT License - see LICENSE file for details
Inspired by the feature request: golang/vscode-go#3667