Case of a leaking timer in go

It was only an accident that I read a post on ArangoDB site and found the same leak in one of our projects at work. So this is going to be quite short, but nevertheless I want for have it in form of a blogpost. Here is how leak looked like: package main import ( "fmt" "runtime" "time" ) func main() { messags := make(chan string) for { select { case msg := <- messages: // do smth with msg fmt....

November 13, 2022 · 2 min · 423 words

VIM cheat sheet

These are my notes on “Mastering VIM” by Ruslan Osipov. Also contains my own knowledge. dd — delete line cc — delete line and go into INSERT mode Movements uppercase is for “words separated by whitespace” e or E — move to the End of the word w or W — move between Words b or B — move Back _ jump to the beginning of the line :N where N is a number line....

June 24, 2022 · 3 min · 493 words

SOLID Go

SOLID is a famous cargo-cult that is used to poke “bad” code during code review. Jokes aside there are some solid, pun intended, ideas within SOLID. This post is yet another attempt to dismantle this set of principles and understand them better. The SOLID stands for(pasted from wiki): S ingle-responsibility principle: “There should never be more than one reason for a class to change.“In other words, every class should have only one responsibility O pen–closed principle: “Software entities … should be open for extension, but closed for modification....

June 6, 2022 · 3 min · 558 words

Notes on Garbage Collection in Golang

Garbage Collection is a process of freeing memory that is allocated and contains some data that is not being used. Notes: by doing escape analysis GC mechanism decides what goes to heap and what stays on stack use -gcflags '-m' flag to get escape analysis info, e.g. go run -gcflags '-m' main.go another way to look into what GC is doing during runtime is to run program with GODEBUG=gctrace=1 GC runs consurrently with main program running main running program is called “mutator” Golang Garbage Collection uses “tricolor algorithm” otherwise known as tricolor mark and sweep algorithm....

June 5, 2022 · 1 min · 141 words

Simple case of profiler usage in golang

So I was solving Construct Binary Tree from Inorder and Postorder Traversal and I got myself more less working solution that got accepted. But it was not the fastest one. But then I though — how do I profile buildTree function and see what actually takes time in my program? Golang has an excellent set of tool available, just check an output of go tool. One of the items in a list you’ll see is pprof which is a Golang profiler....

December 28, 2021 · 32 min · 6674 words