Skip to content

Linux Go Language Guide

Mattscreative edited this page Dec 5, 2025 · 2 revisions

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

  1. Go Installation
  2. Go Workspace
  3. Go Modules
  4. Basic Usage
  5. Troubleshooting

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


This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.

Clone this wiki locally