Category Archives: Programming

Refactor your code and know it’s completely backward compatible

The idea is to run 2 versions of code on production: 1 (control group) — is your old implementation which will be returned to the end user 2 (the experiment) — is a new implementation which results will be checked against the control group and logged It will be run asynchronously and only for a …

Read more

GRPC fallback to Rest API with custom field names

When you generate JSON for Rest API from proto-file, protoc-gen-gofast generates field names for JSON in lowerCamelCase format while most of the Rest APIs use snake_case for that. And if you want to replace some legacy API with your new implementation without breaking backward compatibility, you need to fix it. There could be different ways …

Read more

Integration tests with testcontainers-go

Here is the go library that simplifies integration tests with docker containers — https://github.com/testcontainers/testcontainers-go. That’s how you can use it to test sql — https://github.com/testcontainers/testcontainers-go/blob/master/docs/examples/cockroachdb.md. Project documentation — https://golang.testcontainers.org/features/docker_compose/ The idea is to prepare the environment, build your app, then make requests and check the DB state.

«Awesome go» resources

A list of good resources for each go specific part — https://github.com/avelino/awesome-go. A list of good tools for go performance or just fast libs — https://github.com/cristaloleg/awesome-go-perf Security lists — https://github.com/guardrailsio/awesome-golang-security, https://github.com/Binject/awesome-go-security

Go library for creating slack bots

You can use it like that:

https://github.com/shomali11/slacker

How to work with core dumps of Go programs

If you want to check what is going on in your service during load (on production or during stress testing process), you can take a core dump of your app and load it into Goland for further debugging.

Then open it your Goland: Navigate to Run | Open Core Dump. In the Executable field, …

Read more

Nice introductory article on why Golang is not OOP

It is a copy of this article — https://rakyll.org/typesystem/ It is real struggle to work with a new language, especially if the type doesn’t resemble what you have previously seen. I have been there with Go and lost my interest in the language when it first came out due to the reason I was pretending …

Read more

A way to test http client in go

A couple of ways are described here — http://hassansin.github.io/Unit-Testing-http-client-in-Go The way I liked is the following one:

Go internals

Channels https://youtu.be/KBZlN0izeiY Go scheduler https://youtu.be/YHRO5WQGh0k

Setup local Athens for proper go mod

There is a project called Athens for proxying all your go mod downloads. How to use it locally. 1. Create the following files and directories: a. /Users/d.bolgov/.ssh-athens/storage — empty directory to cache go modules b. /Users/d.bolgov/.ssh-athens/.netrc — if you prefer using .netrc

c. /Users/d.bolgov/.ssh-athens/gitconfig/.gitconfig — if you want to substitue some urls. I personally …

Read more