I've been playing around with Network namespaces recently. I put together a simple code, built it and noticed something very weird happening.
The code is as follows:
http://play.golang.org/p/PYI2E05LnF
Now, when you run this code on Ubuntu Trusty 14.04, I'm seeing something weird happening. This happens when you run the binary several times in a row.
Sometimes it prints out all Host's interfaces, sometimes it simply prints out just a loopback interface which means that the range loop at the end of the program seems to be executing once when the namespace is still attached and sometimes when it's already been detached.
I'm totally confused why this is happening but I'm thinking it's either my code or maybe I'm just missing out something in terms of the Go program execution or some kernel stuff.
Anyone ideas ?
Thanks!
-j