Coming from C#/TypeScript to Go, I’ve learned one thing: Go’s simplicity is its superpower. Let’s walk through a clean, official-compliant setup for Linux and VS Code—no comparisons, just practical steps.


Step 1: Installing Go (Official Linux Method)

Per the Go docs:

  1. Download the tarball:
# Replace the version with the latest from https://go.dev/dl/  
   wget https://go.dev/dl/go1.22.1.linux-amd64.tar.gz
  1. Extract to /usr/local:
sudo rm -rf /usr/local/go  # Remove old installs first  
   sudo tar -C /usr/local -xzf go1.22.1.linux-amd64.tar.gz
  1. Add Go to your PATH:
# Add this line to ~/.bashrc or ~/.zshrc  
   echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc  
   source ~/.bashrc
  1. Verify:
go version  
   # Should output: go1.22.1 linux/amd64

Step 2: Configuring Your Workspace

Go’s official guide recommends modules for dependency management.

  1. Create a project directory:
mkdir ~/go-projects/hello-world && cd ~/go-projects/hello-world
  1. Initialize a module:
go mod init example.com/hello-world  # Replace with your module path

Step 3: VS Code Setup (Without the Headaches)

  1. Install the Go extension.
  2. Open your project in VS Code and create main.go:
package main  

   import "fmt"  

   func main() {  
       fmt.Println("Go + Linux + VS Code: A minimalist’s dream.")  
   }
  1. Install tools:

    • When prompted by VS Code, click “Install All” to set up gopls, dlv, etc.
    • If tools fail (common on Linux), run this in your terminal:
     go install golang.org/x/tools/gopls@latest  
     go install github.com/go-delve/delve/cmd/dlv@latest  
    

Step 4: Build & Run

  • Build a binary:
go build  
  # Outputs an executable named after your module (hello-world)
  • Run:
./hello-world
  • Or run directly:
go run .

Troubleshooting Tips (Linux Edition)

  1. Permission denied for tools?
sudo chown -R $USER $HOME/go  # Reclaim ownership of the Go directory
  1. VS Code not recognizing Go?
    • Restart VS Code after installing the extension.
    • Ensure gopls is installed manually if the prompt fails.

Why This Works

  • No bloat: Go’s static binaries mean no runtime dependencies—ideal for Linux.
  • Official-first approach: Following Go’s docs avoids legacy GOPATH pitfalls.
  • VS Code integration: The Go extension handles formatting, linting, and debugging out of the box.