This workspace contains a collection of Go projects, each focusing on a specific concept or feature of the Go programming language. The projects progress from fundamentals to advanced topics including REST APIs, concurrency, and full-stack applications.
- Description: A simple "Hello, World!" program to get started with Go.
- Files:
main.go
- Description: Demonstrates variable declaration and usage in Go.
- Files:
main.go
- Description: Handles user input and demonstrates how to read from the console.
- Files:
go.mod,main.go
- Description: Covers type conversion in Go.
- Files:
main.go
- Description: Explores working with time and dates in Go.
- Files:
go.mod,main.go
- Description: Introduces pointers and their usage in Go.
- Files:
main.go
- Description: Demonstrates arrays and their operations in Go.
- Files:
go.mod,main.go
- Description: Explains slices, a more flexible alternative to arrays in Go.
- Files:
main.go
- Description: Covers maps, a key-value data structure in Go.
- Files:
main.go
- Description: Introduces structs, a way to define custom data types in Go.
- Files:
main.go
- Description: Demonstrates conditional statements (
if-else) in Go. - Files:
main.go
- Description: Covers the
switchstatement for conditional logic in Go. - Files:
main.go
- Description: Explains looping constructs like
forin Go. - Files:
main.go
- Description: Introduces functions and their usage in Go.
- Files:
main.go
- Description: Demonstrates methods and their association with structs in Go.
- Files:
main.go
- Description: Explains the
deferstatement and its use cases in Go. - Files:
main.go
- Description: Covers file handling, including reading and writing files in Go.
- Files:
main.go,myfile.txt
- Description: Demonstrates how to make HTTP web requests in Go.
- Files:
main.go
- Description: Explains working with URLs and parsing them in Go.
- Files:
main.go
- Description: CLI expense tracker with JSON file persistence. Supports add, list, update, delete, and summary commands with optional month filtering.
- Files:
main.go,expenses.json - Usage:
go run main.go [add|update|delete|list|summary] [flags]
- Description: Advanced JSON encoding and decoding. Demonstrates struct tags (
json:"coursename",json:"-",omitempty), Marshal/Unmarshal, and dynamic parsing withmap[string]interface{}. - Files:
main.go
- Description: Introduces Go modules,
go modcommands, and vendoring. Uses Gorilla Mux for basic HTTP routing with a simple home handler. - Files:
main.go,go.mod,go.sum,vendor/
- Description: REST API for a course catalog. Full CRUD operations using Gorilla Mux with in-memory storage.
- Endpoints:
GET /,GET /courses,GET /course/{id},POST /course,PUT /course/{id},DELETE /course/{id} - Files:
main.go,go.sum - Port: 4000
- Description: Demonstrates the
contextpackage for cancellation and timeouts. Usescontext.WithTimeoutto stop a goroutine after a specified duration. - Files:
main.go
- Description: MongoDB-backed API for a Netflix watchlist. CRUD operations for movies with MongoDB Atlas connection.
- Endpoints:
GET /api/movies,POST /api/movie,PUT /api/movie/{id},DELETE /api/movie/{id},DELETE /api/deleteallmovie - Files:
main.go– Entry pointcontroller/control.go– HTTP handlers and MongoDB operationsmodel/models.go– Netflix struct (ID, Movie, Watched)router/routers.go– Route definitionsgo.mod,go.sum
- Port: 4000
- Description: Concurrent HTTP status checker using goroutines. Fetches status codes from multiple websites with
sync.WaitGroupandsync.Mutexfor thread-safe access. - Files:
main.go,go.mod
- Description: Demonstrates race conditions and synchronization. Uses
sync.RWMutex(Lock/RLock) andsync.WaitGroupfor safe concurrent reads and writes. - Files:
main.go,go.mod
- Description: Introduces Go channels for goroutine communication. Covers buffered channels, send/receive-only channels, and closing channels.
- Files:
main.go,go.mod,go.sum
- Description: Full REST API for todos with JWT authentication. Uses Gin, GORM, and SQLite.
- Files:
main.go– Entry pointconfig/config.go– Environment configurationdatabase/database.go– GORM/SQLite connectioncontrollers/auth_controller.go– Register, Logincontrollers/todo_controller.go– CRUD for todosmiddleware/auth.go– JWT authentication middlewaremodels/todo.go– Todo modelmodels/user.go– User modelroutes/routes.go– Route registrationutils/jwt.go– JWT utilitiesgo.mod,go.sum,todo.db
- Endpoints:
POST /register,POST /login,POST /todos,GET /todos,PUT /todos/:id,DELETE /todos/:id(protected) - Port: 8080
- Navigate to the desired project directory.
- For projects with
go.mod, run:go mod tidy # If dependencies need to be fetched go run main.go - For projects without
go.mod, run from the workspace root or ensure the module path is correct:go run main.go
| Project | Topic | Key Concepts |
|---|---|---|
| 01-04 | Basics | Hello, variables, input, conversion |
| 05-10 | Data structures | Time, pointers, arrays, slices, maps, structs |
| 11-16 | Control flow & functions | if/else, switch, loops, functions, methods, defer |
| 17-19 | I/O & networking | Files, HTTP requests, URLs |
| 20-21 | JSON & CLI | JSON encoding/decoding, CLI apps |
| 22-23 | Modules & APIs | Go modules, REST APIs |
| 24 | Context | Cancellation, timeouts |
| 25 | MongoDB | NoSQL, MongoDB driver |
| 26-28 | Concurrency | Goroutines, mutex, channels |
| todo-api | Full application | Gin, GORM, JWT, SQLite |