Skip to content

A collection of Go examples and practice code while learning the language. Based on exercises and concepts from the official Go documentation and "Go by Example," covering everything from basics to more advanced topics.

Notifications You must be signed in to change notification settings

GauthamKrM/learn-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Learn Go

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.


Table of Contents

  1. About
  2. Folder Structure
  3. How to Run
  4. Credits

About

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.


Folder Structure

Each folder/file focuses on a specific Go concept:

  • 01-hello-world/ – First Go program
  • 02-values/ – Exploring Go’s basic data types
  • 03-variables/ – Declaring and using variables
  • 04-constants/ – Defining constant values
  • 05-for/ – Using for loops for iteration
  • 06-if-else/ – Conditional execution with if-else
  • 07-switch/ – Multi-way branching with switch
  • 08-arrays/ – Working with fixed-size arrays
  • 09-slices/ – Dynamic, flexible slices
  • 10-maps/ – Key-value maps for associative data
  • 11-functions/ – Declaring and calling functions
  • 12-multiple-return-values/ – Functions returning multiple values
  • 13-variadic-functions/ – Functions with variable number of arguments
  • 14-closures/ – Functions that capture surrounding context
  • 15-recursion/ – Functions calling themselves
  • 16-range-over-built-in-types/ – Iterating over arrays, slices, and maps
  • 17-pointers/ – Using pointers to reference memory
  • 18-strings-and-runes/ – Working with text and Unicode
  • 19-structs/ – User-defined composite types
  • 20-methods/ – Functions bound to types
  • 21-interfaces/ – Defining and using abstractions
  • 22-enums/ – Constant values with iota
  • 23-struct-embedding/ – Composition with embedded structs
  • 24-generics/ – Type parameters for reusable code
  • 25-range-over-iterators/ – Iteration with custom iterators
  • 26-errors/ – Error handling using Go’s built-in error type
  • 27-custom-errors/ – Using custom types to define errors
  • 28-goroutines/ – Lightweight concurrent functions using Go’s goroutines
  • 29-channels/ – Communication and synchronization between goroutines using channels
  • 30-channel-buffering/ – Buffered channels to queue values without an immediate receiver
  • 31-channel-synchronization/ – Using channels to coordinate and synchronize goroutines
  • 32-channel-directions/ – Send-only and receive-only channels for clearer communication patterns
  • 33-select/ – Wait on multiple channel operations with select
  • 34-timeouts/ – Implement channel operation timeouts using select and time.After
  • 35-non-blocking-channel-operations/ – Channel operations that proceed immediately without waiting
  • 36-closing-channels/ – Closing channels to signal completion of sends to receivers
  • 37-range-over-channels/ – Use range to receive values from a channel until it is closed
  • 38-timers/ – Timers to schedule actions to run once after a delay
  • 39-tickers/ – Perform actions repeatedly at regular intervals using a ticker
  • 40-worker-pools/ – Distribute work among multiple goroutines using a pool pattern
  • 41-waitgroups/ – Coordinate multiple goroutines using sync.WaitGroup
  • 42-rate-limiting/ – Control frequency of events or requests to prevent overload
  • 43-atomic-counters/ – Safe counter increments using atomic operations
  • 44-mutexes/ – Use sync.Mutex to safely lock and unlock shared data
  • 45-stateful-goroutines/ – Manage shared state safely using a single goroutine and channels
  • 46-sorting/ – Arranging slices and custom collections in a defined order
  • 47-sorting-by-functions/ – Sort slices with custom comparison logic
  • 48-panic/ – Stop execution immediately when an unexpected error occurs
  • 49-defer/ – Execute a function at return
  • 50-recover/ – Handle a panic and resume execution
  • 51-string-functions/ – Common operations and utilities for strings
  • 52-string-formatting/ – Formatting strings using fmt verbs and templates
  • 53-templates/ – Creating and executing text templates using Go's text/template package
  • 54-regular-expressions/ – Pattern matching and text search using Go’s regexp package
  • 55-json/ – Encoding and decoding JSON data using Go’s encoding/json package
  • 56-xml/ – Encoding and decoding XML data using Go’s encoding/xml package
  • 57-time/ – Working with dates, times, durations, and formatting using Go’s time package
  • 58-epoch/ – Working with Unix timestamps using Go’s time package
  • 59-time-formatting-parsing/ – Formatting and parsing time values with Go’s time package
  • 60-random-numbers/ – Generating pseudo-random numbers with Go’s math/rand package
  • 61-number-parsing/ – Convert strings to numbers using Go’s strconv package
  • 62-url-parsing/ – Parse and extract components of URLs using Go’s net/url package
  • 63-sha256-hashes/ – Generate SHA256 checksums using Go’s crypto/sha256 package
  • 64-base64-encoding/ – Encode and decode data using Go’s encoding/base64 package
  • 65-reading-files/ – Read file contents from disk using Go’s os and io packages
  • 66-writing-files/ – Create and write data to files using Go’s os and bufio packages
  • 67-line-filters/ – Process text from standard input and transform or filter it line by line
  • 68-file-paths/ – Manipulate and construct file and directory paths using Go’s path/filepath package
  • 69-directories/ – Create, remove, and read directories using Go’s os package
  • 70-temporary-files-and-directories/ – Create and manage temporary files and directories
  • 71-embed-directive/ – Embed static files and strings into Go binaries at compile time
  • 72-testing-and-benchmarking/ – Writing unit tests and benchmarks in Go using the testing package
  • 73-command-line-arguments/ – Access and handle command-line arguments using os.Args
  • 74-command-line-flags/ – Parse and handle command-line flags using the flag package
  • 75-command-line-subcommands/ – Create and handle subcommands in Go command-line programs
  • 76-environment-variables/ – Access and manage environment variables using os package
  • 77-logging/ – Write and manage logs using the log package
  • 78-http-clients/ – Make HTTP requests and handle responses using net/http
  • 79-http-server/ – Create and handle HTTP servers using net/http
  • 80-context/ – Deadlines, cancellation, and request-scoped values using context package
  • 81-spawning-processes/ – Start and manage external processes using os/exec
  • 82-execing-processes/ – Replace the current Go process with another external process
  • 83-signals/ – Handle Unix signals using os/signal
  • 84-exit/ – Terminate a Go program with a specific exit status

How to Run

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

Credits


About

A collection of Go examples and practice code while learning the language. Based on exercises and concepts from the official Go documentation and "Go by Example," covering everything from basics to more advanced topics.

Topics

Resources

Stars

Watchers

Forks

Languages