For complex refactoring of Go code you can use the Go AST parser and printer to find patterns and replace them with your new code, retaining parameters and variables.

A code base with a lot of simple Go tests wasn’t quite readable and we wanted to remove repetitive assertions using testify. The goal was to implement such conversions:

// before:
err := ThisMightReturnError()
if err != nil {
t.Fatalf("my error: %s", err)
// after:
err := ThisMightReturnError()
require.NotNil(t, "my error: %s", err)

As regexes could solve this, there is an even more interesting solution for (over)engineers: AST rewriting.

Example of an AST


Some might not know, that the whois protocol is simple to use directly from telnet. Just send the requested domain with a <cr><lf> to the service on tcp/43 and you get the response or a pointer to the next whois service.

$ telnet 43
Connected to
Escape character is '^]'. <-- requested domain
% IANA WHOIS server
% for more information on IANA, visit
% This query returned 1 object
refer: whois.nic.chdomain: COM...whois: closed by foreign host.

Now follow the whois pointer:

$ telnet 43
Connected to
Escape character is '^]'. <-- requested domain
Domain Name: MEDIUM.COM
Registry Domain ID: 1329658_DOMAIN_COM-VRSN
Registrar WHOIS Server:
Registrar URL:
Updated Date: 2017-11-06T05:17:00Z
Creation Date: 1998-05-27T04:00:00Z

That’s it

This post shows you how easily it is to compile a WebAssembly module using Go with the latest patches as language.

I’ve been watching the WebAssembly (Wasm) support issue for Go for a long time without trying any patches out. WebAssembly support would be a great benefit for the Go and web community as it allows different languages and technologies to be used crossplatform and sandboxed in a standard webbrowser. Completly without Flash, Silverlight and all other painful stuff. Even without transpiling to JavaScript. It’s a real solution, not a workaround.

Building Go is pretty easy and takes less than…

A discussion about connection possibilities of a Sonos speaker led to an short analysis on how it communicates with other systems. As an exercise I would like to control the volume.

At first I thought Sonos uses a proprietary API because after a quick search on the internet I couldn’t find anything useful. However, after searching for some minutes it turned out that there are open protocols in use.

nmap found the IP address of my Sonos Play:5 and I searched for open TCP ports on this device:

# nmap -p1–65535 Nmap 7.50 ( ) at 2017–07–24…

Data is money, data is business. After reading this you will know how and where PostgreSQL stores your important data.

PostgreSQL holds all of its data and configuration in one directory called PGDATA which you can find on most systems under /var/lib/pgsql/data/. There are three directories where tables will be stored:

  • base: Databases in pg_default tablespace
  • global: Cluster wide tables which don’t belong to a database e.g. pg_authid (tablespace pg_global)
  • pg_tblspc: Symbolic links to other tablespaces, which can reside outside PGDATA

Every database has its own directory named after the OID (Object Identifier) which you can query with an SQL…

Boris Djurdjevic

Linux, Go, Container, PostgreSQL, Infosec

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store