Category Archives: golang

Another cool article on using PostgreSQL+pgBouncer with go

Extremely interesting and very practical talk about problems occurring with go+pgBouncer (in Russian, sorry). https://habr.com/ru/company/oleg-bunin/blog/461935/ And a video on that: https://www.youtube.com/watch?v=Uojy57I-xP0

env-file parser for Goland

You can use env-file parser for running and debugging your app in Jetbrains’ products like Goland. It’s pretty simple and works. https://github.com/Ashald/EnvFile

How golang garbage collection works

It is a Mark-and-Sweep GC. Phases Mark Stop-the-World: Set write barrier (to know how much was allocated during maark phase) Concurrent: Mark all memory which is still in use by the app Stop-the-World: Remove write barrier Concurrent: Sweep (it actually happens on new allocations) Details/Algorithm It’s a tri-color process: grey for objects to check, black …

Read more

Style guide for golang project file structure

Highly recommended. It has a couple of odds like not explaining about /test dir (I assume, they wanted to say to put there only e2e and other integrational tests, not unit-test as the latter should be kept together with the code itself in files like …_test.go). But it’s awesome in general. https://github.com/golang-standards/project-layout

Golang patterns. Worker pool

Further reading: https://gobyexample.com/worker-pools

PgBouncer and prepared statements

In our system, we use connection pooler called PgBouncer as a proxy to PostgreSQL server. PgBouncer has two main modes Session pooling mode This mode is less performant (it’s a default mode). When a client connects, a server connection will be assigned to it for the whole duration it stays connected. So it does not …

Read more

Golang: testing http and grpc servers

HTTP server is quite easy to test — here is a nice video about it:

How go code is being compiled to assembler code

https://go.godbolt.org/z/31FyJ3 I was interested in comparing line 15 vs line 17 of the following code:

E2E tests in go

I tried it via ginkgo and gomega. It has Agouti with WebDriver support out of the box, but I didn’t use it as we have grpc API. That’s the example (table tests):

ORM for go

https://github.com/Masterminds/squirrel Never used it as we always write SQL queries manually. But looks okay for ORM (well, actually a query-builder).