Skip to main content
โšก Calmops

IDE Setup: GoLand Professional Guide

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

  1. Download from jetbrains.com/go
  2. Install for your operating system
  3. Launch GoLand
  4. 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

  1. Open GoLand
  2. Create new project or open existing
  3. GoLand automatically detects Go installation
  4. Configure Go SDK if needed:
    • File โ†’ Project Structure โ†’ Project
    • Select Go SDK version

Go SDK Configuration

  1. File โ†’ Project Structure โ†’ SDKs
  2. Click “+” to add new SDK
  3. Select Go SDK installation directory
  4. Verify version and path

Essential Settings

Code Style

  1. File โ†’ Settings โ†’ Editor โ†’ Code Style โ†’ Go
  2. Configure:
    • Indentation: Tabs (Go standard)
    • Line length: 120 characters
    • Imports: Organize automatically

Go Modules

  1. File โ†’ Settings โ†’ Go โ†’ Go Modules
  2. Enable “Enable Go Modules integration”
  3. Set proxy: https://proxy.golang.org
  4. Configure GOPROXY and GOSUMDB if needed

Formatting and Linting

  1. File โ†’ Settings โ†’ Tools โ†’ Go โ†’ Linter
  2. Enable gofmt for formatting
  3. Enable golangci-lint for linting
  4. Configure linting rules

Run Configurations

  1. Run โ†’ Edit Configurations
  2. Add new “Go” configuration
  3. Set:
    • Package: ./cmd/myapp or .
    • Working directory: Project root
    • Program arguments: As needed

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

  1. Set breakpoints by clicking on line numbers
  2. Run โ†’ Debug (Shift+F9)
  3. Use Debug panel to inspect variables
  4. 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

  1. View โ†’ Tool Windows โ†’ Run
  2. Shows all tests in project
  3. Run individual tests or test files
  4. View test results and coverage

Coverage

  1. Run โ†’ Run with Coverage
  2. Coverage is displayed with highlighting
  3. Green = covered, red = uncovered
  4. 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

  1. File โ†’ Settings โ†’ Editor โ†’ Live Templates
  2. Create custom templates for common patterns
  3. 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

  1. File โ†’ Settings โ†’ Editor โ†’ Inspections
  2. Enable/disable inspections
  3. Configure severity levels
  4. Run โ†’ Run Inspections

Version Control Integration

Git Integration

  1. VCS โ†’ Enable Version Control Integration
  2. Select Git
  3. 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

  1. View โ†’ Tool Windows โ†’ Database
  2. Add new data source
  3. Configure connection
  4. Browse tables and run queries

Terminal Integration

Built-in Terminal

  1. View โ†’ Tool Windows โ†’ Terminal
  2. Run commands directly in IDE
  3. Integrated with project environment

Plugins

  1. File โ†’ Settings โ†’ Plugins
  2. 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

  1. File โ†’ Settings โ†’ Appearance & Behavior โ†’ System Settings
  2. Disable unnecessary plugins
  3. Increase heap size if needed:
    • Help โ†’ Edit Custom VM Options
    • Increase -Xmx value

Exclude Directories

  1. File โ†’ Project Structure โ†’ Modules
  2. Mark directories as excluded:
    • vendor/
    • node_modules/
    • .git/

Troubleshooting

GoLand Not Finding Go SDK

  1. File โ†’ Project Structure โ†’ Project
  2. Select Go SDK manually
  3. Verify installation path

Debugging Not Working

  1. Verify Delve is installed: dlv version
  2. Restart GoLand
  3. Check debug configuration

Slow Performance

  1. Disable unnecessary plugins
  2. Increase heap size
  3. Exclude large directories
  4. Update GoLand to latest version

Best Practices

โœ… Good Practices

  1. Use keyboard shortcuts - Faster than mouse
  2. Configure code style - Consistent formatting
  3. Use debugging - Understand code behavior
  4. Run tests frequently - Catch issues early
  5. Use version control - Track changes
  6. Enable inspections - Catch problems
  7. Use templates - Speed up coding
  8. 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