Generate All Boolean Array Combinations

While writing Go tests for goxplorer, I wanted to test all boolean flags combinations without having to cascade for loops. This first method came to mind: package main import ( "fmt" ) func stob(bf []bool, s string) { for i, b := range s { if b == '0' { bf[i] = false } else { bf[i] = true } } } func main() { bf := []bool{false, false, false, false, false} for i := 0; i < 32; i++ { b := fmt.

Is LevelDB 2 times faster than BadgerDB? (Update: No)

Update (2020/05/21) the method used in this post is totally sub-performant, and I finally found out about LevelDB’s and Badger’s batch methods, which make writes considerably faster, I’ll probably write another note about this. And by the way, I found Badger to be much faster at writing batches than LevelDB. Actual post I’m working on a plugin for Goxplorer that will create a database of all Bitcoin addresses present in its blockchain.

Gitlab CI caching for Go projects

The reference documentation when it comes to couple golang and continuous integration in Gitlab is this one, it’s well put, easy to read and pretty accurate. Except for the caching part, or at least nowadays with go modules. This is what happens when a commit is pushed with the .gitlab-ci.yml given as an example in that document: 131 Creating cache default... 132 WARNING: /apt-cache: no matching files 133 WARNING: /go/src/github.com: no matching files 134 WARNING: /go/src/gitlab.

Understanding golang channel range... again

In a previous article, I tried to explain my understanding of go channels interaction with ranges. Turns out my explanation was probably not clear enough because here I am, nearly a year after, struggling to achieve pretty much the same exercise. So here we go again, on a good old trial and error fashion progress. The goal here is to retrieve channel messages that are pushed from go routines created in a for loop.

proof-of-work based blockchain explained with golang

Yet another “blockchain explained” article, I know, I really thought about if releasing it or not, but you know, you only understand what you can explain clearly, so I hope I’ll be able to explain proof of work and blockchain as clearly as it is clear in my mind. The originality of this post is that I’ll try to make those concepts clear through pieces of code extensively explained so it doesn’t feel like a theoretical expose where you get the idea without the taste.

golang reflection tips

Because I’m the kind of person who likes genericity, I often find myself using features of languages that are flagged as “only use it if you know what you’re doing”. Golang reflection is one of those features, powerful yet a bit confusing. Reflection, as explained in The Laws of Reflection is the ability of a program to examine its own structure, particularly through types; it’s a form of metaprogramming In short, you can introspect variables at run-time, making your program exceptionally dynamic.

Understanding golang channel range

Here we go again with my golang self teaching, today with a topic I had hard time understanding correctly (and hope I actually did): range over channels along with goroutines. First of all, let’s have a little reminder. We all know a goroutine live its own life and must be waited for at the main level, i.e. in this example: package main import "fmt" func main() { go func() { fmt.

Golang interfaces, a pragmatic explanation for the programmer

I’m still in the process of learning golang the right way. Yes I already wrote some projects with the Go language (here and here), but I like to understand the real meaning of techniques when using them. One of what is said to be the most amazing features of Go is interfaces. Here’s what the official golang docs has to say about it: Interfaces in Go provide a way to specify the behavior of an object: if something can do this, then it can be used here.