Author Archives: bullgare

Debugging go app in Jetbrains Goland on m1

First download a proper version of GoLand here — select .dmg (MacOS Apple Silicon) here (direct link — https://www.jetbrains.com/go/download/download-thanks.html?type=eap&platform=macM1&build=211.6556.11&code=GO). Then make sure you are using arm version of go (go version go1.16.2 darwin/arm64). If not, download and install arm version of golang (like «go1.16.2.darwin-arm64.pkg») from the list here — https://golang.org/dl/. Now it should work. With …

Read more

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:

Run Steam on MacBook with m1 chip (apple silicon)

You need to install Crossover. Then you need to install Steam there. Good video explaining the process of installing Steam on Apple Silicon chips: https://www.youtube.com/watch?v=3TdCV7fn2CA Here is the list of supported games — https://applesilicongames.com/

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/

mmock for mocking microservices

It is a very easy to set up though pretty powerful tool with support for delays and handling query params. It also has a console for checking all the requests and corresponding responses matched. Here it is https://github.com/jmartin82/mmock. Below I describe a way to use it with docker-compose for local development.

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).