This repository is a hands-on learning playground for Golang (Go 1.25).
It covers basic concepts like project structure, modules, data types, variables, pointers, memory, and Unicode handling, with simple examples you can run and modify.
- Go 1.25 or newer fsdfdsf
Check your Go version:
go version
Getting Started
If your project does not have a Go module yet, initialize it with:
go mod init <module_name>
Run or build the project:
go run .
go build
Useful Go CLI Commands
Some common Go commands:
go build # Compile packages and dependencies, creates executable
go run # Compile and run
go clean # Remove object files and cached files
go doc fmt # Show documentation for fmt package
go env # Show Go environment variables
go bug # Start a bug report
Repository Structure
01-InstallAndPlugin/ – Installation notes and tooling
02-StructureAndModule/ – Project structure and Go modules
03-DataType.go – Examples of Go data types
04-Variables/01-Declaration/ – Variable declaration examples
dataType/ – Data type and memory-related examples
helper.go – Helper functions used in examples
Data Types & Memory
Size of Types
Go provides unsafe.Sizeof to check how much memory a variable uses:
unsafe.Sizeof(x)
The size of int is platform-dependent (32-bit or 64-bit).
You can check it using:
bits.UintSize
Floating-point types have fixed sizes:
float32 → 4 bytes
float64 → 8 bytes
Value Types vs Reference Types
Types like int, float, struct, array are value types (copied by value).
Types like slice, map, channel, function, and pointer behave like reference types (they refer to underlying data).
Pointers
Example:
var j int = 10
var jp *int = &j
*int means “pointer to int”
jp stores the address of j
&j means “address of j”
*jp means “the value at that address”
Stack, Heap, and Garbage Collector (GC)
Go uses both stack and heap memory.
The compiler decides where variables live (escape analysis).
The Garbage Collector (GC) works on the heap:
It finds objects that are no longer reachable
Frees their memory automatically
You don’t manually free memory in Go.
Strings, Runes, and Unicode
Go strings are byte slices under the hood.
Some characters (like Persian, Arabic, or emoji 😄) use multiple bytes.
If you iterate over a string by bytes, you may break characters.
Always prefer using rune or for range when working with Unicode text:
for _, r := range s {
fmt.Println(r)
}
rune represents a Unicode code point.
Go standard libraries provide strong Unicode support for multilingual text.
Note on Python (Comparison)
Python uses pass by assignment (object references are passed by value).
Go is explicit:
Value types are copied
Reference-like types (slices, maps, pointers, etc.) refer to shared data
This makes Go’s behavior more predictable once you understand the model.
Goal of This Repository
Learn Go fundamentals step by step
Understand memory, types, pointers, and Unicode correctly
Build a strong mental model of how Go works
Prepare for real-world Go, backend, and DevOps use cases 🚀