This repository contains code which I used to learn Go. Hoping it can be useful to someone, I've uploaded them here in github.
This is a very basic Go application which prints a simple string
This is a Go application which uses the Docker Go SDK and communicates with the Docker API. It outputs lists of containers, images, networks and swarm nodes. Check my blog post about this https://www.melvinvivas.com/learning-go-with-docker-sdk/
This is my first microservice using the Go Language which connects to a MongoDB NoSQL database, compiled using Docker a multi-stage build, and deployed as a Docker container. The microservice exposes 2 HTTP endpoints
- GET /jobs - this endpoint returns a list of jobs retrieved from a MongoDB database
- POST /jobs - this endpoint accepts a json string and saves it to a MongoDB database
Check my blog post about this https://www.melvinvivas.com/my-first-go-microservice/
In this example, I decoupled the saving of data to MongoDB and created another microservice to handle this. I also added Kafka to serve as the messaging layer so the microservices can work on its own concerns asynchrounously.
The REST microservice which receives data from a /POST http call to it. After receiving the request, it retrieves the data from the http request and saves it to Kafka. After saving, it responds to the caller with the same data sent via /POST
The microservice which subscribes to a topic in Kafka where Microservice 1 saves the data. Once a message is consumed by the microservice, it then saves the data to MongoDB.
Check my blog post about this https://www.melvinvivas.com/developing-microservices-using-kafka-and-mongodb/
I've been studying about pointers in golang and these are the source codes which I used to understand pointers.