This repository houses a collection of Go projects and code snippets that I've developed for educational purposes.
Folder with services that run complete flows.
- auto-import-users: Service that reads, from time to time, an API that returns random users in a random quantity. After reading user data, it is incremented to a .json file in the
./files
folder. With this data saved in the file, after a specific number of increments in the file, it is read, deleted and saved in a MongoDB database (accessible through docker-compose.yaml from the root). Reading and writing to the file is controlled using an auxiliary variable that blocks writing during reading so that deletion does not result in data loss.
Folder with scripts for manipulating MongoDB. Is accessible by docker-compose.yaml from the project root
- hello-world: Database connection test that creates a
"hello-world"
collection (if it does not exist), cleans the documents in this collection and adds a single{"hello":"world"}
. - users: Script that adds users provided from an API every 3 records at each run.
Folder with files containing tests for using goroutines and communication channels.
- channels.go: Execution of two goroutines that share common channels. One goroutine prints numbers and another prints letters. They are executed together and only after the registration of the completion channels is the flow completed.
- routines.go: Basic goroutine execution tests.
Folder with files for consuming external APIs via HTTP.
- random-data-api.go: Reads data from a random API, which can return data from a user, an address or a appliance.
- cat-api.go: Consumption of an API that returns random cat species data.
Folder with scripts for file manipulation.
- incrementing-json.go: Script that increments json results from a cat API into a common file.
- incrementing-file.go: Script that increments lines in a text file.