A personal repository to learn and practice the Go programming language.
This repo contains examples and exercises from the official Go Getting Started guide and Go by Example.
The goal of this repository is to document my journey of learning Go through hands-on examples.
It starts from the basics (syntax, types, functions) and gradually covers more advanced concepts such as concurrency, interfaces, and error handling.
Each folder/file focuses on a specific Go concept:
01-hello-world/– First Go program02-values/– Exploring Go’s basic data types03-variables/– Declaring and using variables04-constants/– Defining constant values05-for/– Using for loops for iteration06-if-else/– Conditional execution with if-else07-switch/– Multi-way branching with switch08-arrays/– Working with fixed-size arrays09-slices/– Dynamic, flexible slices10-maps/– Key-value maps for associative data11-functions/– Declaring and calling functions12-multiple-return-values/– Functions returning multiple values13-variadic-functions/– Functions with variable number of arguments14-closures/– Functions that capture surrounding context15-recursion/– Functions calling themselves16-range-over-built-in-types/– Iterating over arrays, slices, and maps17-pointers/– Using pointers to reference memory18-strings-and-runes/– Working with text and Unicode19-structs/– User-defined composite types20-methods/– Functions bound to types21-interfaces/– Defining and using abstractions22-enums/– Constant values with iota23-struct-embedding/– Composition with embedded structs24-generics/– Type parameters for reusable code25-range-over-iterators/– Iteration with custom iterators26-errors/– Error handling using Go’s built-in error type27-custom-errors/– Using custom types to define errors28-goroutines/– Lightweight concurrent functions using Go’s goroutines29-channels/– Communication and synchronization between goroutines using channels30-channel-buffering/– Buffered channels to queue values without an immediate receiver31-channel-synchronization/– Using channels to coordinate and synchronize goroutines32-channel-directions/– Send-only and receive-only channels for clearer communication patterns33-select/– Wait on multiple channel operations with select34-timeouts/– Implement channel operation timeouts using select and time.After35-non-blocking-channel-operations/– Channel operations that proceed immediately without waiting36-closing-channels/– Closing channels to signal completion of sends to receivers37-range-over-channels/– Use range to receive values from a channel until it is closed38-timers/– Timers to schedule actions to run once after a delay39-tickers/– Perform actions repeatedly at regular intervals using a ticker40-worker-pools/– Distribute work among multiple goroutines using a pool pattern41-waitgroups/– Coordinate multiple goroutines using sync.WaitGroup42-rate-limiting/– Control frequency of events or requests to prevent overload43-atomic-counters/– Safe counter increments using atomic operations44-mutexes/– Use sync.Mutex to safely lock and unlock shared data45-stateful-goroutines/– Manage shared state safely using a single goroutine and channels46-sorting/– Arranging slices and custom collections in a defined order47-sorting-by-functions/– Sort slices with custom comparison logic48-panic/– Stop execution immediately when an unexpected error occurs49-defer/– Execute a function at return50-recover/– Handle a panic and resume execution51-string-functions/– Common operations and utilities for strings52-string-formatting/– Formatting strings using fmt verbs and templates53-templates/– Creating and executing text templates using Go's text/template package54-regular-expressions/– Pattern matching and text search using Go’s regexp package55-json/– Encoding and decoding JSON data using Go’s encoding/json package56-xml/– Encoding and decoding XML data using Go’s encoding/xml package57-time/– Working with dates, times, durations, and formatting using Go’s time package58-epoch/– Working with Unix timestamps using Go’s time package59-time-formatting-parsing/– Formatting and parsing time values with Go’s time package60-random-numbers/– Generating pseudo-random numbers with Go’s math/rand package61-number-parsing/– Convert strings to numbers using Go’s strconv package62-url-parsing/– Parse and extract components of URLs using Go’s net/url package63-sha256-hashes/– Generate SHA256 checksums using Go’s crypto/sha256 package64-base64-encoding/– Encode and decode data using Go’s encoding/base64 package65-reading-files/– Read file contents from disk using Go’s os and io packages66-writing-files/– Create and write data to files using Go’s os and bufio packages67-line-filters/– Process text from standard input and transform or filter it line by line68-file-paths/– Manipulate and construct file and directory paths using Go’s path/filepath package69-directories/– Create, remove, and read directories using Go’s os package70-temporary-files-and-directories/– Create and manage temporary files and directories71-embed-directive/– Embed static files and strings into Go binaries at compile time72-testing-and-benchmarking/– Writing unit tests and benchmarks in Go using the testing package73-command-line-arguments/– Access and handle command-line arguments using os.Args74-command-line-flags/– Parse and handle command-line flags using the flag package75-command-line-subcommands/– Create and handle subcommands in Go command-line programs76-environment-variables/– Access and manage environment variables using os package77-logging/– Write and manage logs using the log package78-http-clients/– Make HTTP requests and handle responses using net/http79-http-server/– Create and handle HTTP servers using net/http80-context/– Deadlines, cancellation, and request-scoped values using context package81-spawning-processes/– Start and manage external processes using os/exec82-execing-processes/– Replace the current Go process with another external process83-signals/– Handle Unix signals using os/signal84-exit/– Terminate a Go program with a specific exit status
Make sure you have Go installed.
# Clone the repository
git clone https://github.com/GauthamKrM/learn-go
cd learn-go
# Run an example
go run 01-hello-world/main.go- The Go Programming Language – For the language and standard library
- Go by Example – The primary tutorial source for all examples