Recent Post

Iterators in Go

Go has always been a simple language from its inception. Perhaps too simple. I personally think of Go as a (successful) MVP of a programming language. With garbage collector, channels and goroutines. This simplicity is the reason why many developers, myself included, love Go. And at the same time why so many other developers hate the language. Go getting better While in core Go remain simple language, it does not prevents an evolution....

Less tracking of readers

When I moved my blog to self hosted virtual machine, I later realised that the content itself was still calling external services for web fonts and css and a javascript. It makes no sense to move from Microsoft owned Github Pages to self-hosted and force users to visit Google, unpkg.org and cdnjs.cloudflare.com every time they visit my humble blog. Self-hosted Starting from today the blog server hosts FiraSans and FiraCode fonts instead of relying on Google Fonts pure-min....

Fearless BDD for Go

I like the Go’s built-in support for testing, especially table-driven ones. At the same time I always have a problem with how to structure the test properly. It is easy to write something, but it is hard to read, adapt or improve the test in the future. Ruby developers know their RSpec, which enforces a test structure. Then there is the Given-When-Then naming convention introduced by Cucumber or Selenium tests. Let us explore the advantages and find out the simple way on how to write well structured tests in idiomatic Go....

My blog runs on Kubernetes and I like it

As I approach that famous middle age now, I realised that most of my online presence is controlled by big US companies. Pretty ironic for someone who has been using Linux and open source for decades, isn’t? So I went through a bit of a transformation process starting with deleting my Twitter account. Right after THE takeover. And joined the Fediverse at @vyskocilm@witter.cz. After Bram died I joined https://opencollective.com/neovim as a financial contributor....

Go programming language has a new version 1.21. Release Notes. Each new release contains a lot of great stuff and 1.21 is not an exception. In fact it’s pretty massive. New numbering scheme, so the 21 in 1.21.0 is a Go language version. However still under v1 compatibility promise There are many changes aroung GOTOOLCHAIN and the fact go 1.21 in go.mod has now a meaning The ability to download and use a specific toolchain version....

Turris Omnia and syncthing

The Turris Omnia router is an unusual device. Manufacturers tend to abandon their devices after a while, forcing their customers to buy shiny new hardware. The good souls behind the Omnia, the Czech domain registry CZ NIC, have a different strategy. They are constantly improving and enhancing their offering to existing customers. Syncthing integration The https://syncthing.net/ is an open source file synchronization tool. Simply speaking. It can transfer files from A to B, or from B to A, or to mirror changes between A and B....

@hintjensquotes@botsin.space: a server-less Mastodon bot

Why and how I built the simply server-less @hintjensquotes@botsin.space bot. And my tribute to Pieter. Recently I setup the Mastodon bot serving quotes of Pieter Hintjens. Pieter was one of the most influential man I ever met. And I do consider his ideas as brilliant, though-provoking, sometimes counter intuitive and typically in a sharp opposition to industry practices. His list of achievements is amazing, he was a president of Foundation for a Free Information Infrastructure fighting the software patents in Europe....

Testify: make Go testing easy 3/3

While Go comes with go test and a testing package by default, the experience can be better with testify package. Git hub page introduces it as Go code (golang) set of packages that provide many tools for testifying that your code will behave as you intend. By the end I found the resulting article as too long (~25 minutes) to read, so I split it into Part1 introduces assert, talks briefly abot Python and C and shows basics of testify Part2 introduces table driven testing, more helpers like ElementsMatch or JSONeq Part3 gets more advanced with test suited and mocks Test suites While testing documentation encourages table driven tests and subtests, there are many developers outside, who are used to write Smalltalk like unit tests and this style encourages writing test suites....

Testify: make Go testing easy 2/3

While Go comes with go test and a testing package by default, the experience can be better with testify package. Git hub page introduces it as Go code (golang) set of packages that provide many tools for testifying that your code will behave as you intend. By the end I found the resulting article as too long (~25 minutes) to read, so I split it into Part1 introduces assert, talks briefly abot Python and C and shows basics of testify Part2 introduces table driven testing, more helpers like ElementsMatch or JSONeq Part3 gets more advanced with test suited and mocks Table driven testing Table driven testing is common and usefull go idiom....

Testify: make Go testing easy 1/3

While Go comes with go test and a testing package by default, the experience can be better with testify package. Git hub page introduces it as Go code (golang) set of packages that provide many tools for testifying that your code will behave as you intend. By the end I found the resulting article as too long (~25 minutes) to read, so I split it into Part1 introduces assert, talks briefly abot Python and C and shows basics of testify Part2 introduces table driven testing, more helpers like ElementsMatch or JSONeq Part3 gets more advanced with test suited and mocks Standard approach Example as it comes with a testing package from the standard library....

Easy way to check go.mod replace via Linux namespaces

The common problem for monorepo and go modules is that the following It is really easy to miss the go.mod replace directive In a following text we will learn more about Linux, namespaces and container technologies like Docker or Podman. The problem While go build is awesome tool, doing a lot of things in the background has sometimes consequences. And the typical consequences is when we build the software from an environment without network access....

Correct Usage of Sql Transaction in Postgres From Go

Problem Once upon a time I got a task to merge duplicate URLs in our production database. It turned out that there were a lot of same urls like https://example.com?fbclid=1234 and https://example.com?fbclid=5678 we wanted to merge. Code to normalize URL was easy to develop. Code to migrate the database looked easy as weel. Until I turned the transaction on. Then very cryptic message appeared pq: unexpected Parse response 'C' The error message was telling me nothing....