1. What is Go
Go (Golang) is a:
- high-performance,
- statically typed programming language
- designed by Google.
It’s optimized for:
- simplicity,
- efficiency &
- scalability.
[See 4. Advantages of Go for more information]
2. Install Go on WSL
Instructions: https://go.dev/doc/install
2.1 Pre-download:
- Update Packages:
sudo apt update
- Install necessary dependencies:
sudo apt install wget tar
2.2 Download & Install:
Downloads List: https://go.dev/dl/
- Download Go Binary
wget https://golang.org/dl/go1.24.0.linux-amd64.tar.gz
- Move Go Binary to
/usr/local
:mv go1.24.0.linux-amd64.tar.gz /usr/local
- If you don’t move it you’ll be greeted with some lovely errors upon untarring.
- Create Fresh Go Tree via Untarring:
sudo rm -rf /usr/local/go && tar -C /usr/local -xzf go1.24.0.linux-amd64.tar.gz
2.3 Add Go Binary to Path
Environment Variable:
- Add following line:
export PATH=$PATH:/usr/local/go/bin
- To local profile:
$HOME/.profile
2.4 Check Go Install
Restart Linux then:
go version
3. Hello World
3.1 Setup
- Create folder:
mkdir gday && cd gday
- Create Go Module:
go mod init example/gday
- Create Go Script:
code gday.go
- Enter code into
gday.go
script
3.2 Run .Go
Script
go run .
4. Advantages of Go
4.1 Performance & Efficiency
- Compiled to native machine code:
- Faster execution than interpreted languages (e.g., Python, JavaScript).
4.2 Concurrency & Scalability
- Goroutines:
- lightweight threads
- Better concurrency handling than OS threads.
- Channel-based concurrency:
- Safer than traditional multithreading.
- Ideal for high-performance network services & APIs.
4.3 Simplicity & Fast Development
- Minimalistic syntax
- No complex OOP:
- No inheritance.
- No classes.
- Uses simple structs & interfaces.
- Fast compilation & execution:
- Great for CI/CD pipelines.
4.4 Cross-Platform & Portability
- Write once, compile anywhere:
- GOOS and GOARCH allow easy cross-compilation (e.g., Linux, Windows, macOS).
- Small, self-contained binaries:
- No need for dependencies or interpreters.
4.5 Built-in Tools & Standard Library
- Powerful standard library:
- Comes with built-in support for HTTP servers, JSON handling, cryptography, concurrency, etc.
- Go modules for dependency management:
- No external package managers needed.
4.6 Memory Safety & Garbage Collection
- Automatic garbage collection:
- Helps manage memory efficiently.
- Avoids memory leaks & segmentation faults:
- Common in C/C++.