Golang tip of the day; PHP-compatible crc32

Submitted by Frederic Marand on

While porting (well, actually rewriting) an old PHP library to Go, I had to use a CRC (cyclic redundancy check) on a buffer. In old-school PHP, the standard is well established since PHP 4: just use crc32 from the strings package, and beware of the sign bit or, to be a bit more current while still compatible, use the hash() function from the hash package, like this example:

Go tip of the day : running tests for all subpackages recursively

Submitted by Frederic Marand on

If you program in Go, you've probably written a lot of packages, and probably split packages in subpackages. Maybe even more than idiomatic Go would really advise... And you may have been grumbling just like I did at the fact that the go test command requires a list of packages, and does not recursively dive into all the subpackages, like PHPunit would, and does not seem to have a working recursion flag.

Debugging spammer mechanics

Submitted by Frederic Marand on

I've long been receiving quite high volumes of comment spam on this blog, which is why comments have always been pre-moderated. And, of course, there is usually not much to think of it. Not so with one of the spam messages posted today, which unwittingly provided an unexpected insight into the current mechanisms uses by spammers.

Golang tip of the day: admin dashboard and health checks in Beego applications

Submitted by Frederic Marand on

One litle-publicized feature of the BeeGo Go framework is its admin dashboard.

Features

Although it may look quite raw visually (think MIME: text/plain), it contains a wealth of information about goroutines, threads, memory usage, and request statistics. It even allows devs to add to a "healthcheck" list, and admins allowed dashboard access to run "tasks" defined in code. The diagram belows shows the hierarchy of features in the version coming with Beego 1.3.0.

What to do when Go will not run, nor install from source ?

Submitted by Frederic Marand on

Some days ago, at the AWS Summit 2014, DamZ renewed my long-sleeping interest for the Google Go language with wonderous stories about its use in infrastructure of the new Commerce Guys Platform they were launching that same days, so I've been doing my homework getting up to date on Go programming: that's what holidays are for, aren't they ?

Tip of the day: Phing, Composer and namespaced Task classes

Submitted by Frederic Marand on

Among the interesting features of Phing is its extensibility, and of the hallmarks of that exensibility is the ability to define new Task types as PHP classes, which are by default located in the default namespace only. Can we do better ?

Step 0: "Ad-hoc" (inline) tasks

At the simplest, Task classes are created by embedding ad-hoc tasks like: