Quick way to combine io.Reader and io.Closer

There are many interesting tools in Golang’s standard library to wrap io.Reader instance such as io.LimitedReader or cipher.StreamReader. But when wrapping a io.ReadCloser instance, the Close method is hidden. Here’s a quick code snippet to combine wrapped io.Reader and the original io.Closer through an inline struct to rebuild the io.Closer interface. Code var rc io.ReadCloser = struct { io.Reader io.Closer }{ Reader: r, Closer: c, } What it is about? The io....

January 22, 2023

Throttling Pool

In my last post I presented few techniques useful for limiting simultaneous operations in Go. Such throttlers are indeed a very neat tools to keep our resources under control. However we can be extended that idea to even better tool for resource control when we mix throttlers with object pools. Object pools in go Even though golang has a very efficient memory management system, there are some cases where we would like to manage the memory by ourselves....

November 22, 2022

Throttling in Go

Go language makes a good job at making hard things simple. It compiles the code so that it runs fast, it comes with garbage collector so we don’t have to deal with memory management, it has lightweight goroutines and we don’t have to think a lot about concurrency limits. And in majority of cases all those language constructs combined with sane defaults will be good enough. Just like writing a web server....

October 7, 2022

Multi-CPU Github Actions with Go

When we think about CPU architecture usually there’s one leader that comes to our mind - the famous x86-64 one. It is the main player on our desktops and on the server side. Even more recent generation of game consoles switched to that architecture from some more exotic ones. But there are alternatives. Some are pretty well known such as the ARM one that took over the mobile market (and slowly enters the desktop world with Apple M1 laptops)....

July 19, 2022

K-DAG University

Last time I briefly described the knowledge in the form of a Graph structure. Each term having set of prerequisites is a node in this graph, each dependency is a directed edge in such graph. Now let’s assume this graph is a directed acyclic one and there are no terms which form a cycle of dependencies. In reality I don’t believe this to be true but it does simplify reasoning and can definitely be achieved locally for larger terms....

July 14, 2019

Knowledge DAG

If I have some specific problem to solve, I find technology that seems relevant, then I scan the Internet for some basic introduction, then some tutorial, then documentation. My usual problem is that the issue I want to solve is usually not in the introduction nor the tutorial. I rarely find ready-to-use solution and unfortunately I tend to really dislike adjusting my idea to what you can easily achieve with tutorial-like solutions....

July 10, 2019

Boot

Yeah, one of the hardest things - materialize your thoughts. We’re living in a world full of digital content. People write, produce, record, put so many things into the Internet that it’s very easy to just get lost in all this informational chaos. Will this blog share the same fate? Most likely, not going to lie here. Honestly I’m not sure if the information I could throw into the big information highway will be that meaningful....

July 6, 2019