Golang tutoriel GVM et go IRIS

Install Golang

In this article we will use GVM to manage multiple Golang version.

bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
. .bashrc
gvm install go1.4.3
gvm use go1.4.3
gvm install go1.6.2
gvm use go1.6.2 --default

If you have some trouble to compile go1.4.3, you can use binary version

gvm install go1.6.2 --binary

Prepare your environment

mkdir -p dev/go/my-project/{src,pkg,bin}
cd dev/go/my-project
gvm pkgset create --local
gvm pkgset use --local

create a basic Iris project

Fix Iris 3rc GOPATH bug

export GOPATH=$PWD

create it

go get -u -v github.com/iris-contrib/middleware/logger
go get -u -v github.com/kataras/iris/iris
iris create 

Go Unit Test

any files ended by « _test.go » will be consider as a test.
to execute it:

go test

in verbose mode

go test -test.v

to have teardown / setup in your unit test you can add a TestMain function to your test like

func TestMain(m *testing.M) {
        // setup test
        // run tests	
        code := m.Run()
        // clear env


50 Shades of Go

Nautilus – GLib Library Hack to sort file like LS

You can find my github project at https://github.com/heralight/GlibSortFileNameHackLibrary

For years, everybody list files on unix based on LC_COLLATE.
Then Gnome developpers decide to interpret number in filename…

Strange choice, and we cannot personalize this.

ls show something like

001  004  1  A  B  a  b

and for example, nautilus show:

1 001  004  A  B  a  b

This behavior use command g_utf8_collate_key_for_filename from Glib library.
Thank you to
* https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/322271
* https://bugzilla.gnome.org/show_bug.cgi?id=355152
* https://bugs.launchpad.net/ubuntu/+source/thunar/+bug/684317
* + 30 related bugs opened

This little override this function with g_utf8_collate_key.


Compilation dependencies

sudo apt-get install libglib2.0-dev


make all

Install and usage

To override this behavior, this library need to be preload before each program who use Glib library.
Todo that you can

set it before call from command line or from .desktop shortcut:

LD_PRELOAD=/pathToYourLib/glibSortFileNameHack.so nautilus

set globally on gnome session:

echo "export LD_PRELOAD=/pathToYourLib/glibSortFileNameHack.so" >> ~/.gnomerc

and restart your gnome session. Be careful, this settings produce effect on whole gnome session.

or more simply

make install

this command will create a libs directory in your home, copy library, and append LD_PRELOAD to ~/.gnomerc


Before open an issue, please follow this guide

Test required

to verify that it works, create some dummy files.


touch 001
touch 004
touch 1
touch 4
touch a
touch A
touch b
touch B

ls will show:

001  004  1  4  a  A  b  B

nautilus on a standard installation will show:

1 001 4 004  a  A  b  B

With hack nautilus will show

001  004  1  4  a  A  b  B


before anything, kill any nautilus process

ps -aux | grep nautilus
kill -9 nautilusProcess

launch it from lib directory to test it:

LD_PRELOAD=./glibSortFileNameHack.so nautilus .

Related bug : https://bugzilla.gnome.org/show_bug.cgi?id=754777

Enjoy !

Log4Net – Multi configuration

Pour avoir une configuration de Log4net propre à chaque configuration de votre solution, vous pouvez utiliser les XDT transformations , une implémentation automatisée est fourni par l’extension SlowCheetah avec interface graphique pour Visual Studio.
Une fois cette extension installée, clic-droit sur le fichier log4net.config et sélectionner « Add Transform ».

2 sous-fichiers sont ajoutés:

+—- log4net.Debug.config
+—- log4net.Release.config

La transformation la plus simple, « Replace », est faîte en ajoutant le tag xml xdt:Transform= »Replace » sur le noeud que vous souhaîtez remplacer.


<log4net xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xdt:Transform="Replace">

Remplacera le noeud log4net complet.

Un exemple de résultat log4net est ci-inclus .

Vous pouvez pré visualiser la transformation en effectuant un clic droit sur la version debug ou release et en sélectionnant « Preview Transform » .

La syntaxe de transformation est définie dans la documentation disponible sur:

MSDN Doc Xdt transform