This repository contains the code examples used on the CodelyTV course.
- Go v1.15+
- MySQL (see below).
This project has been designed as a single Go module with multiple applications. Each folder contains a completely functional application (binary) that can be executed isolated.
Each folder corresponds to one of the course lessons / videos:
01-01-your-first-http-endpoint
- Nuestro primer endpoint HTTP en Go01-02-using-gin
- Usando Gin: nuestro primer framework01-03-architectured-healthcheck
- Arquitecturando nuestro health check02-01-post-course-endpoint
- Implementando el endpoint de creación de curso02-02-repository-injection
- Inyectando nuestro repositorio02-03-controller-test
- Testeando nuestro endpoint02-04-domain-validations
- Añadiendo validaciones a nuestro dominio03-01-mysql-repository-implementation
- Implementando nuestro repositorio para MySQL03-02-repository-test
- Testeando nuestro repositorio04-01-application-service
- Refactorizando el endpoint para extraer el Application Service04-02-application-service-test
- Testeando el Application Service04-03-command-bus
- Unificando nuestros casos de uso: Command Bus05-01-graceful-shutdown
- Graceful shutdown05-02-timeouts
- Timeouts en operaciones asíncronas: repositorio06-01-http-middlewares
- Usando middlewares HTTP en Go06-02-time-parse-in-go
- El secreto mejor guardado de Go y sus fechas06-03-gin-middlewares
- Implementando el middleware de recuperación de errores en Gin07-01-publishing-domain-events
- Publicando eventos de curso creado07-02-domain-events-subscriber
- Implementando nuestro suscriptor de eventos07-03-event-bus-implementation
- Implementando el Event Bus08-01-reading-env-variables
- Leyendo configuración de variables de entorno08-02-build-and-deploy
- Build, despliegue y ¡a producción!08-03-debugging
- Generando la imagen de Docker y depurando errores
To execute the application from any lesson, just run:
export COURSE_LESSON=02-04-domain-validations; go run $COURSE_LESSON/cmd/api/main.go
Replacing COURSE_LESSON
value by any of the available ones.
Some lessons only contain a single main.go
file with a few lines of code.
To run one of those lessons, just run:
export COURSE_LESSON=01-01-your-first-http-endpoint; go run $COURSE_LESSON/main.go
From 02-01-post-course-endpoint
on, the application on each directory relies
on a MySQL database. So, to simplify its execution, we've added a
docker-compose.yaml
file with a MySQL container already set up.
To run it, just execute:
docker-compose up -d
You can also use your own MySQL instance. Note that those applications
expects a MySQL instance to be available on localhost:3306
,
identified by codely:codely
and with a codely
database.
To set up your database, you can execute the schema.sql
file
present on the sql
directory. It's automatically loaded if
you use the provided docker-compose.yaml
file.
To execute all tests, just run:
go test ./...
To execute only the tests present in one of the lessons, run:
go test ./02-04-domain-validations/...