Category Archives: golang

How to make grpc call from shell

1 https://github.com/grpc/grpc/blob/master/doc/command_line_tool.md

2 https://github.com/fullstorydev/grpcurl

How to analyze the performance of your go application in production

You should definitely use chi’s middleware for running pprof and stuff in your admin panel. That’s the repo — https://github.com/go-chi/chi That’s the profiler — https://github.com/go-chi/chi/blob/master/middleware/profiler.go CPU profiling After that you can run something like this in shell:

Or just open it in the browser:

If it opens something different then your browser (sublime …

Read more

Using GOPROXY with go mod

Nice list of image resizer libs in go

With speedtests and other nice things. https://github.com/fawick/speedtest-resize I tried these two: https://github.com/disintegration/imaging https://github.com/bamiaux/rez They are quite the same talking about file sizes and imaging is muuch easier to use.

Mocking for testing go code

If you’re testing go code and have a huge API you have to mock, you have two options: make your dummy struct with embedded interface and implement only methods you need, or use your own interface that has only methods you need (and change your code to use that). For instance, I had amazon’s s3 …

Read more

BDD Framework For Golang

There is a good one: https://github.com/onsi/ginkgo It prefers to use http://onsi.github.io/gomega/ as a matcher.

Golang, PostgreSQL and array_agg

If you have SQL like this:

Container insights for golang engineer (k8s docker CPU throttling)

We’ve run into problems on my work when k8s limits cpu to few processors (throttling), while go application can see all of them (setting GO_MAX_PROCS to maximum CPUs available) and go’s scheduler is going crazy because of that during highload (like stress-tests). It is caused by scheduling for, let’s say, 40 processors while you have …

Read more

Особенности структур в go

Методы на структурах в golang определяются на типе. И если мы объявим типизированную переменную, даже не проинициализировав её, методы будут работать корректно до тех пор, пока мы не попытаемся обратиться к полям ресивера. Вот пример; первые два вызова работают нормально, третий валится с паникой.

GO. Реализация бинарного дерева

https://appliedgo.net/bintree/