Linux Go Language Guide - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Linux Go Language Guide
Complete beginner-friendly guide to Go programming language on Linux, covering Arch Linux, CachyOS, and other distributions including installation, workspace setup, and development.
Table of Contents
Go Installation
Install Go
Arch/CachyOS:
# Install Go
sudo pacman -S go
# Or latest from golang.org
Debian/Ubuntu:
sudo apt install golang-go
Fedora:
sudo dnf install golang
Verify Installation
Check Go:
# Check version
go version
# Check environment
go env
Go Workspace
Setup Workspace
Create workspace:
# Create workspace
mkdir -p ~/go/{bin,pkg,src}
# Set GOPATH
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
Go Modules
Modern Go (modules):
# Initialize module
go mod init example.com/project
# Build
go build
# Run
go run main.go
Basic Usage
Hello World
Create program:
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
Build and Run
Compile:
# Build
go build main.go
# Run
./main
# Or run directly
go run main.go
Troubleshooting
Go Not Found
Check installation:
# Check Go
which go
# Install if missing
sudo pacman -S go
Module Errors
Fix modules:
# Download dependencies
go mod download
# Tidy modules
go mod tidy
Summary
This guide covered Go installation, workspace setup, and development for Arch Linux, CachyOS, and other distributions.
Next Steps
- Development Environment - Development setup
- VS Code Guide - VS Code setup
- Go: https://go.dev/
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.