This repository was created to study Golang concepts including GoRoutines, testing, database (sqlite3), RabbitMQ, docker and K8S (Kubernetes)
First class
Second class
Third class
To run the project, you must have the dependencies installed, then run the commands below
remember to clone db.sqlite3 to the location of the file being executed
To execute the API run the command below
The API run on 8888 port
To access the API use the URL: http://localhost:8888/order
Method: POST
Body: {price: 10.00, tax: 1.5}
go run cmd/api/main.go
OR execute the executable file
cmd/api/api.exe
To execute the consumer for rabbitMQ run the command below
To run the rabbitMQ with docker run the command: docker-compose up -d
To access rabbitMQ management open the link: http://localhost:15672
User: guest
Password: guest
go run cmd/order/main.go
To send a message to rabbitMQ run the command below
go run cmd/publisher/main.go
OR execute the executable file
cmd/publisher/publisher.exe
Need to have Golang installed To execute the API run the command below
The API run on 8888 port
To access the API use the URL: http://localhost:8888/order
Method: POST
Body: {price: 10.00, tax: 1.5}
make go_api
OR
go run cmd/api/main.go
To execute the consumer for rabbitMQ run the command below
To run the rabbitMQ with docker run the command: docker-compose up -d
To access rabbitMQ management open the link: http://localhost:15672
User: guest
Password: guest
make go_msg
OR
go run cmd/order/main.go
To send a message to rabbitMQ run the command below
go run cmd/publisher/main.go
OR execute the executable file
cmd/publisher/publisher.exe
To execute the project with k8s run the command below (need to have kind installed)
make k8s_up
This command will create the cluster, pod and service
To clear the project with k8s run the command below
make k8s_down
This command will delete the cluster, the pod and the service that was created
Go has its own Threads, which are known as Go Routines: Co-Routines / userland / light threads / green and consume 2kb of memory
Go Channels was created to solve race conditions
Race condition is a common problem that occurs in concurrent programming, where two threads modify the same resource simultaneously, which can generate unexpected results.
go mod init github.com/gustavohenriquess/go-intensive23
go test ./...
go mod tidy
defer db.Close()
defer is used to perform the action after the function that called it returns
kind create cluster
kubectl cluster-info
kubectl get nodes
kubectl create -f pod.yaml
kubectl delete -f pod.yaml
kubectl get pods
kubectl get pods -o wide
kubectl create -f service.yaml
kubectl get svc
kubectl get svc -o wide
kubectl delete -f service.yaml
kubectl port-forward svc/goapp-service 8888:8888