Recent Post

cover image

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

cover image

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

cover image

Implement Sql Database Driver in 100 Lines of Go

Go database/sql defines interfaces for SQL databases. Actual driver must be implemented in own package. And dependency injection is done as a part of import and build system. Lets go deeper to see how it is actually implemented. This exercise will result in a simple driver backed up by csv files. Who do not want to SELECT from csv file? Disclaimer: I wrote it in order to learn database/sql and to learn more about design of APIs for go....

cover image

Speeding Your Ci With Go Mod Download Again

Running go mod download slows down each CI run a lot. More dependencies increases time and it wastes the bandwidth again and again. As we do use special CI containers for the task, then go modules can be downloaded during container build phase and CI build will benefit from it. There are many articles about this topic. However most of them discuss one go module per repository or Docker image. As I wrote recently, we do use monorepo with many go modules....

cover image

Adblocking in Turris Omnia

As a long time Firefox user I was horrified to use web browser with very limited blocking capabilities. However Samsung Browser is very handy tool for some sites. However the number of spam, scam, or porn pages and advertisements makes browsing there very unpleasant experience. Especially if your kids want to browse that way. However I bought Turris Omnia especially because I wanted to hack around. Source: turris.cz Options As router provides Doman Name Service for all devices in local network, the most common way is to block DNS lookups for specified domains....

cover image

Golang CORS and Testing

Working on a web project spread in more domains brings you to Cross-Origin Resource Sharing. Browsers use it to if it code from one origin can call HTTP methods placed elsewhere. Responses must contain specific headers, like Access-Control-Allow-Origin, which must match requesting Origin of the site issuing the call. More information about CORS can be found at html5rocks. CORS look like simple thing to develop. Just add a few HTTP headers for regular methods....

cover image

Go 111 Modules Monorepo and Shared Code

I recently joined company as a Python developer. However it turns out there is bigger need to evolve their code written in golang (and PHP and Javascript). I am not an expert in go, so it took me a while to figure things out. However I love to learn new things and to solve new puzzles (the real ones, there is nothing more boring to solve artificial ones for me)...

cover image

Limiting Your Gorutines

Limiting your goroutines How to properly implement goroutine pool in golang with input and output channel(s). Text expects knowledge about golang and about Go Concurency. That means I am not going to explain what goroutine, channel or defer actually are. Intro Gorutines are some kind of lightweight threads managed by userspace golang runtime. They save memory and context switches. Therefor it is possible to spawn literally Millions! of them. However as BenPar^W Voltaire said...

cover image

'Modern' Javascript Development for Oldies

My Javascript experience When I started my career, I was working as Junior Developer on web based application. We have had parts written in Java Server Pages, which was great technology combining elegance of PHP with easy to use of Java. We had something in Java servlets, which allows us easier testing and compilation up front. Other parts were in PL/SQL. And of course, the Javascript. And most of our clients has been using Internet Explorer 6 at the time!...

cover image

Make your /usr/local user writable

About I am the long term user of Linux based operating systems. And as a C developer mostly working on stuff built by GNU autotools. Therefor I need to quickly build, install and test new versions of the software. I usually make changes to lower layers (like zeromq/czmq). Typical advice for Linux is to not run things as a root! What is root Linux operating systems are multi user ones. Each user account have own documents and can’t interfere with others....