IDE Setup: GoLand Professional Guide
GoLand is JetBrains’ professional IDE for Go development. It provides powerful features for code editing, debugging, testing, and refactoring. This guide covers setting up and using GoLand effectively.
Installation
Installing GoLand
- Download from jetbrains.com/go
- Install for your operating system
- Launch GoLand
- Complete the initial setup wizard
Licensing
- Community Edition: Free, limited features
- Professional Edition: Paid subscription, full features
- Free Trial: 30-day trial of Professional Edition
Initial Configuration
Project Setup
- Open GoLand
- Create new project or open existing
- GoLand automatically detects Go installation
- Configure Go SDK if needed:
- File โ Project Structure โ Project
- Select Go SDK version
Go SDK Configuration
- File โ Project Structure โ SDKs
- Click “+” to add new SDK
- Select Go SDK installation directory
- Verify version and path
Essential Settings
Code Style
- File โ Settings โ Editor โ Code Style โ Go
- Configure:
- Indentation: Tabs (Go standard)
- Line length: 120 characters
- Imports: Organize automatically
Go Modules
- File โ Settings โ Go โ Go Modules
- Enable “Enable Go Modules integration”
- Set proxy:
https://proxy.golang.org - Configure GOPROXY and GOSUMDB if needed
Formatting and Linting
- File โ Settings โ Tools โ Go โ Linter
- Enable gofmt for formatting
- Enable golangci-lint for linting
- Configure linting rules
Run Configurations
- Run โ Edit Configurations
- Add new “Go” configuration
- Set:
- Package:
./cmd/myappor. - Working directory: Project root
- Program arguments: As needed
- Package:
Code Editing Features
IntelliSense and Completion
- Ctrl+Space: Basic completion
- Ctrl+Shift+Space: Smart completion
- Ctrl+P: Parameter info
- Ctrl+Q: Quick documentation
Code Navigation
- Ctrl+Click: Go to definition
- Ctrl+Alt+B: Go to implementation
- Ctrl+Shift+I: Quick definition
- Ctrl+H: Type hierarchy
- Ctrl+F12: File structure
Refactoring
- F2: Rename
- Ctrl+Alt+M: Extract method
- Ctrl+Alt+V: Extract variable
- Ctrl+Alt+C: Extract constant
- Ctrl+Alt+P: Extract parameter
Debugging
Setting Up Debugging
- Set breakpoints by clicking on line numbers
- Run โ Debug (Shift+F9)
- Use Debug panel to inspect variables
- Step through code with F10 (step over) or F11 (step into)
Debug Configuration
Create .idea/runConfigurations/Debug.xml:
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Debug" type="GoApplicationRunConfigurationType" factoryName="Go Application">
<option name="CGO_ENABLED" value="false" />
<method v="2" />
</configuration>
</component>
Debugging Features
- Breakpoints: Click line number to set
- Conditional breakpoints: Right-click breakpoint
- Watch expressions: Add in Debug panel
- Evaluate expression: Alt+F9
- Step into: F11
- Step over: F10
- Step out: Shift+F11
- Continue: F9
Testing Integration
Running Tests
- Ctrl+Shift+F10: Run test under cursor
- Ctrl+Shift+F9: Debug test under cursor
- Ctrl+Alt+Shift+F10: Run all tests in file
- Ctrl+Alt+Shift+F9: Debug all tests in file
Test Explorer
- View โ Tool Windows โ Run
- Shows all tests in project
- Run individual tests or test files
- View test results and coverage
Coverage
- Run โ Run with Coverage
- Coverage is displayed with highlighting
- Green = covered, red = uncovered
- View coverage report
Productivity Features
Keyboard Shortcuts
| Action | Shortcut |
|---|---|
| Format Code | Ctrl+Alt+L |
| Organize Imports | Ctrl+Alt+O |
| Go to Definition | Ctrl+Click |
| Find Usages | Ctrl+F7 |
| Rename | F2 |
| Extract Method | Ctrl+Alt+M |
| Quick Fix | Alt+Enter |
| Run | Shift+F10 |
| Debug | Shift+F9 |
Code Templates
- File โ Settings โ Editor โ Live Templates
- Create custom templates for common patterns
- Use abbreviations for quick insertion
Example template:
func Test$NAME$(t *testing.T) {
tests := []struct {
name string
}{
{"test case"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
$END$
})
}
}
Code Inspections
- File โ Settings โ Editor โ Inspections
- Enable/disable inspections
- Configure severity levels
- Run โ Run Inspections
Version Control Integration
Git Integration
- VCS โ Enable Version Control Integration
- Select Git
- Configure Git executable path
Git Operations
- Ctrl+K: Commit
- Ctrl+Shift+K: Push
- Ctrl+T: Update
- Ctrl+Alt+Z: Revert
- Ctrl+Shift+A: Show Git log
Database Tools
Database Integration
- View โ Tool Windows โ Database
- Add new data source
- Configure connection
- Browse tables and run queries
Terminal Integration
Built-in Terminal
- View โ Tool Windows โ Terminal
- Run commands directly in IDE
- Integrated with project environment
Plugins
Recommended Plugins
- File โ Settings โ Plugins
- Search and install:
- Protocol Buffers: For protobuf support
- Docker: For Docker integration
- Kubernetes: For Kubernetes support
- GitHub Copilot: For AI code completion
Performance Optimization
Optimize IDE Performance
- File โ Settings โ Appearance & Behavior โ System Settings
- Disable unnecessary plugins
- Increase heap size if needed:
- Help โ Edit Custom VM Options
- Increase
-Xmxvalue
Exclude Directories
- File โ Project Structure โ Modules
- Mark directories as excluded:
vendor/node_modules/.git/
Troubleshooting
GoLand Not Finding Go SDK
- File โ Project Structure โ Project
- Select Go SDK manually
- Verify installation path
Debugging Not Working
- Verify Delve is installed:
dlv version - Restart GoLand
- Check debug configuration
Slow Performance
- Disable unnecessary plugins
- Increase heap size
- Exclude large directories
- Update GoLand to latest version
Best Practices
โ Good Practices
- Use keyboard shortcuts - Faster than mouse
- Configure code style - Consistent formatting
- Use debugging - Understand code behavior
- Run tests frequently - Catch issues early
- Use version control - Track changes
- Enable inspections - Catch problems
- Use templates - Speed up coding
- Keep GoLand updated - Latest features and fixes
โ Anti-Patterns
// โ Bad: Using mouse for everything
// Slower than keyboard shortcuts
// โ
Good: Use keyboard shortcuts
// Ctrl+Alt+L for formatting
// F2 for renaming
// โ Bad: Ignoring warnings
// Warnings indicate potential issues
// โ
Good: Fix warnings
// Use Alt+Enter for quick fixes
Comparison with VS Code
| Feature | GoLand | VS Code |
|---|---|---|
| Cost | Paid | Free |
| Performance | Heavier | Lighter |
| Features | More built-in | Extensible |
| Debugging | Excellent | Good |
| Testing | Excellent | Good |
| Refactoring | Excellent | Good |
| Learning Curve | Steeper | Gentler |
Summary
GoLand is a powerful IDE for Go:
- Professional features for production development
- Excellent debugging and testing support
- Powerful refactoring tools
- Integrated version control
- Customizable and extensible
- Great for large projects
Choose GoLand for professional Go development with advanced features.
Comments