Category Archives: Programming

Example of using embed in go

Nice article on using go templates with embed introduced in go1.16: https://philipptanlak.com/web-frontends-in-go/. That’s the code:

Embedding assets to go binary in go 1.16

That’s how you can use it:

Or embedding one file directly into a variable:

More details — https://golang.org/pkg/embed/

Forward multiple kubernetes pods for local development

kubefwd is a great tool that can forward a lot of pods at once to your local machine. The only downside for me is that it touches your local /etc/hosts. That’s how I use it:

It does not have huge documentation, but it is written in golang, and you can check how the source …

Read more

XDebug inside a docker container

That’s how you can debug your php app running in a docker container.

Force ipv4 for golang http client

Sometimes you want to prevent your http client from using ipv6/tcp6. That’s how you do it.

Mocking for unit-tests and e2e-tests in golang

Some patterns to test your golang app. Mocking an interface

https://github.com/vektra/mockery Mocking SQL database

https://github.com/DATA-DOG/go-sqlmock Mocking HTTP server for unit-tests

https://golang.org/pkg/net/http/httptest/ Stubbing HTTP server for e2e-tests

https://github.com/jmartin82/mmock Mocking for e2e-tests with dockertest

https://github.com/ory/dockertest

Install go2 beta on MacOS

A quick guide on installing golang v2 development revision. It works for my MacOS Big Sur (with an Intel processor).

Using DataDog on your CentOs

https://app.datadoghq.eu/logs/onboarding/server https://docs.datadoghq.com/agent/faq/error-restarting-agent-already-listening-on-a-configured-port/ Or, if you want a dockerized version of DataDog agent, and you want to listen to docker logs, you can do this:

More info here — https://docs.datadoghq.com/agent/docker/log/?tab=containerinstallation Then you will see your logs here — https://app.datadoghq.eu/logs

Install go with gvm on MacOS Big Sur

I used to use gvm for this — https://github.com/moovweb/gvm. But initial installation of go from scratch does not work for Big Sur as 1.4 does not have a binary for this OS (this command fails — gvm install go1.4 -B). To use gvm, you can do this: 0. Install gvm — bash <

Complete list of swagger options to protobuf file

Here is an example with many options that help generate proper swagger out of protofile. Original URL — https://raw.githubusercontent.com/grpc-ecosystem/grpc-gateway/master/examples/internal/proto/examplepb/a_bit_of_everything.proto.