Skip to content

Instantly share code, notes, and snippets.

View amanbolat's full-sized avatar

Amanbolat amanbolat

View GitHub Profile
@amanbolat
amanbolat / 01_go_simple_round_robin_example.md
Last active March 4, 2024 21:12
Load balancing in golang

Round robin example in Go

An example of a round robin algorithm in Go that can be used for load balancing.

@amanbolat
amanbolat / 01_go_interview_question_#1.md
Last active March 4, 2024 21:09
Go Interview Question #1

Go Interview Question #1

  • Read the code and explain it.
  • Will it compile or not?
  • Find any possible issues.
  • Explain how would you refactor it and why.

Microservice project structure

I suggest to use the following project structure for any microservice which usually is deployed using container image on kubernetes, exposes its core logic through HTTP or gRPC transport layers and interacts with other services using a message broker, such as kafka.

root/
├── cmd/
@amanbolat
amanbolat / 01_Makefile_with_pinned_version_of_protoc.md
Last active March 4, 2024 21:06
Makefile with pinned version of protoc and protoc-gen-go

Makefile with pinned version of protoc

This gist includes two files, Makefile and the script.

Script downloads the protoc for a given os and arch, unzips the files to .bin directory. It won't download the zip file, if it was already downloaded.

Makefile provides gen-prot entry point that ensures that protoc exists and generates the code from given proto files.

This setup ensures that the protoc and plugins versions are pinned and there is no need to donwload those tools manually.