Go Runner - Auto Restart Server
🚀 The ultimate VS Code extension for Go development with hot reloading!
Automatically restart your Go server when files change, making development faster and more efficient. No more manual restarts - just code and see your changes instantly!
✨ Features
- 🎯 One-command solution: Single command starts Go server with auto-restart enabled
- 🔥 Smart file watching: Automatically restarts server when .go files change (excludes test files)
- ⚡ Lightning fast: Optimized process management for quick restarts
- 🛡️ Robust: Handles process cleanup, port conflicts, and edge cases
- 🎛️ Configurable: Customize file watching patterns and exclusions
- 📊 Detailed logging: View server logs and restart activity in VS Code output
- 🧠 Intelligent: Ignores test files so you can write tests without interruption
🎮 Commands
Command |
Description |
Keyboard Shortcut |
Go Runner: Start Go Server with Auto-Restart |
Start the Go server and enable file watching |
Ctrl+Shift+G S (Windows/Linux)
Cmd+Shift+G S (Mac) |
Go Runner: Stop Go Server |
Stop the running Go server and disable file watching |
Ctrl+Shift+G X (Windows/Linux)
Cmd+Shift+G X (Mac) |
🚀 Quick Start
- Install the extension from the VS Code Marketplace
- Open a Go project in VS Code (must have
main.go
or go.mod
)
- Start the server: Press
Ctrl+Shift+P
→ type "Go Runner" → select "Start Go Server with Auto-Restart"
- Code away! The server automatically restarts when you save
.go
files
- View logs in the "Go Runner" output channel
- Stop when done: Use "Go Runner: Stop Go Server" command
📋 Requirements
- ✅ Go installed: Go must be installed and available in your PATH
- ✅ Valid Go project: Your project should have a
main.go
file or go.mod
file
- ✅ VS Code 1.74+: Compatible with VS Code version 1.74.0 and above
⚙️ Configuration
Customize the extension behavior through VS Code settings:
Setting |
Description |
Default |
goRunner.watchPatterns |
File patterns to watch for changes |
["**/*.go"] |
goRunner.excludePatterns |
File patterns to exclude from watching |
["**/vendor/**", "**/node_modules/**", "**/*_test.go", "**/test/**"] |
Example Configuration
{
"goRunner.watchPatterns": ["**/*.go", "**/*.mod"],
"goRunner.excludePatterns": [
"**/vendor/**",
"**/node_modules/**",
"**/*_test.go",
"**/test/**",
"**/testdata/**"
]
}
🔧 How It Works
The extension uses advanced process management to ensure reliable server restarts:
- Process Groups: Creates detached process groups to track parent and child processes
- Smart Killing: Kills entire process trees, not just the parent
go run
process
- Port Cleanup: Automatically finds and kills processes using common Go server ports
- Debounced Restarts: Prevents multiple restarts from rapid file changes
- Error Recovery: Handles port conflicts and process cleanup automatically
🐛 Troubleshooting
Server won't start
- ✅ Ensure Go is installed:
go version
- ✅ Check your project has
main.go
or go.mod
- ✅ Verify no other process is using the port
- ✅ Check the "Go Runner" output channel for errors
Server won't restart on file changes
- ✅ Ensure you're editing
.go
files (not test files)
- ✅ Check file patterns in settings
- ✅ Verify the server is actually running
- ✅ Try stopping and starting again
Port conflicts
- ✅ The extension automatically handles port cleanup
- ✅ If issues persist, manually kill processes:
lsof -ti:8080 | xargs kill -9
- ✅ Try using a different port in your Go code
- ✅ Adjust
goRunner.excludePatterns
to ignore more files
- ✅ Use more specific
goRunner.watchPatterns
- ✅ Ensure your project isn't too large
🤝 Contributing
Found a bug or want to contribute? We'd love your help!
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
📝 Changelog
See CHANGELOG.md for version history.
👨💻 Author
Sri Jayan E - Passionate Software Developer
Publisher: astro-byte
📄 License
MIT License - see LICENSE file for details.
Made with ❤️ for the Go community
If you find this extension helpful, please ⭐ star the repository and leave a review!