Skip to content

saurav470/golang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Learning Project: Beginner to Advanced

A comprehensive Go (Golang) learning environment with structured modules covering everything from basics to advanced concepts, web development, concurrency, databases, and design patterns.

📚 What You'll Learn

🔹 Beginner Level

  • Variables & Types: All Go data types, constants, type conversion
  • Control Flow: if/else, switch, for loops, defer
  • Functions: First-class functions, closures, recursion, variadic functions
  • Collections: Arrays, slices, maps, and operations

🔸 Intermediate Level

  • Structs & Methods: Custom types, composition, receivers
  • Interfaces: Polymorphism, empty interface, type assertions
  • Error Handling: Error types, wrapping, panic/recover
  • Pointers: Memory addresses, pointer receivers

🔺 Advanced Level

  • HTTP Servers: Building web servers with net/http
  • RESTful APIs: JSON APIs, middleware, CRUD operations
  • Goroutines & Channels: Concurrent programming
  • Context & Sync: Cancellation, timeouts, WaitGroups, Mutexes
  • Databases: SQL operations with SQLite
  • Testing: Unit tests, table-driven tests, benchmarks
  • Design Patterns: Factory, Singleton, Builder, Strategy, Observer
  • Packages & Modules: Creating reusable packages, Go module system
  • Performance Optimization: sync.Pool, sync.Map, memory management
  • Large Data Processing: 1BRC techniques, chunking, worker pools, sharding

🚀 Quick Start

Run the Demo

go run cmd/demo/main.go

Run Individual Examples

Basics:

go run examples/01-basics/variables-types/main.go
go run examples/01-basics/control-flow/main.go
go run examples/01-basics/functions/main.go
go run examples/01-basics/collections/main.go

Structs & Interfaces:

go run examples/02-structs-interfaces/structs/main.go
go run examples/02-structs-interfaces/interfaces/main.go
go run examples/02-structs-interfaces/error-handling/main.go
go run examples/02-structs-interfaces/pointers/main.go

Web Development:

# Start HTTP server
go run examples/03-http-server/basic-server/main.go

# Start REST API server
go run examples/04-rest-api/main.go

Concurrency:

go run examples/05-concurrency/goroutines/main.go
go run examples/06-advanced-concurrency/context/main.go

Database:

go run examples/07-database/sql-basics/main.go

Testing:

cd examples/08-testing
go test -v                # Run tests with verbose output
go test -cover            # Run tests with coverage
go test -bench=.          # Run benchmarks

Design Patterns:

go run examples/09-patterns/main.go

Packages & Modules:

cd examples/10-packages-modules/app
go run main.go

Performance Optimization:

go run examples/11-performance/main.go

Large Data Processing:

go run examples/12-large-data-processing/main.go

📁 Project Structure

golang-learning-project/
├── cmd/
│   └── demo/               # Main demo application
├── examples/
│   ├── 01-basics/          # Beginner concepts
│   ├── 02-structs-interfaces/  # OOP-like concepts
│   ├── 03-http-server/     # Web servers
│   ├── 04-rest-api/        # RESTful APIs
│   ├── 05-concurrency/     # Goroutines & channels
│   ├── 06-advanced-concurrency/  # Context & sync
│   ├── 07-database/        # SQL operations
│   ├── 08-testing/         # Testing & benchmarks
│   ├── 09-patterns/        # Design patterns
│   ├── 10-packages-modules/  # Go modules & packages
│   ├── 11-performance/     # Performance optimization
│   └── 12-large-data-processing/  # 1BRC techniques
├── pkg/                    # Reusable packages
├── internal/               # Private application code
└── api/                    # API definitions

💡 Best Practices Demonstrated

  • ✅ Idiomatic Go code
  • ✅ Proper error handling
  • ✅ Table-driven tests
  • ✅ Thread-safe concurrent code
  • ✅ RESTful API design
  • ✅ Clean architecture patterns
  • ✅ Extensive documentation

🔧 Requirements

  • Go 1.23 or higher
  • No external dependencies for most examples (uses standard library)
  • SQLite driver for database examples (auto-installed)

📖 Resources Referenced

This project is built using:

🎓 What Makes This Different

  • Beginner-Friendly: Starts from absolute basics
  • Progressive: Builds complexity gradually
  • Practical: Real-world examples, not toy code
  • Comprehensive: Covers all major Go features
  • Well-Documented: Every file has detailed explanations
  • Runnable: All examples can be executed immediately

🤝 Contributing

Feel free to:

  • Add more examples
  • Improve documentation
  • Fix bugs
  • Suggest new topics

📝 License

This is a learning project - use it however you like!


Happy Learning! 🚀

Master Go from beginner to advanced and build production-ready applications.

doubt

go run examples/01-basics/collections/main.go 186 > doubt how slice appaned array and capacity vs length -> solution type slice struct { array unsafe.Pointer // pointer to the underlying array point zero index of array len int // number of elements in the slice cap int // number of elements in the underlying array (capacity) }

completed (status)

examples/01-basics/collections/main.go

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages