Category Archives: golang

DDD/Clean Architecture go linters

Origin (in Russian) Tech talk (paid access only, unfortunately): Presentation: Linters Dependencies between layers: Others: — to check using all microtypes in enums/switches. + — to prevent using struct tags in Domain models (Value Objects). — to prevent changing Value Objects (Domain models) from outside of the …

Read more

Protobuf: safer usage for buf

A drop-in replacement for buf issued by Ozon. Repository: Presentation (for subscribers only, unfortunately):

Maps internals in Go

Idea Map is passed as a value, but it consists of a pointer to hmap which has all the details on map implementation. So, if you change/add to map, it will be reflected everywhere. And that’s why you cannot assign to an uninitialized map (no memory allocated, no hash seed generated yet). runtime/map.go

Buckets …

Read more

Go’s Concurrency and Channel Internals

Go is implementing CSP (Communicating Sequential Processing): processes are communicating through channels, they can block each other while waiting for read/writes to channels. Actor model makes inter-process communications more explicit and non-blocking. CSP vs Actor explained — Channels requirements goroutine-safe store and pass data across goroutines FIFO can block/unblock goroutines

Protobuf: add header parameters

They finally added it to the grpc-gateway: So, to use it you can just update to the version 2.14.0 or above —, and add something like this to your protofile:

Go scheduler details

Scheduler was implemented by Dmitry Vyukov in go 1.1 and lives in runtime/proc.go. Good resources — video by Dmitry Vyukov (slides as pdf) — nice article by Bill Kennedy in 3 parts. Most of the images below are taken from this article. Main ideas Goroutines are very light weight (~2KB+) and very cheap …

Read more

Golang. Adding a json body to POST request in protofile

It could be a bit tricky, and I failed to find a good example for it.

Mock sql (sqlx) db on golang

I am using this library — That’s how you can use it for mocking db querying:

How to install multiple versions of go on mac m1

For instance, I want to try a new beta, go1.18beta2 (I check if it’s available on the download page). And I already have a regular go1.17, that I want to use as a default one. To do so, I need to do this:

Then I can check if it’s okay — go1.18beta2 version #go …

Read more

Useful links for proto generator development