How does your OS see goroutines? If you’re beginning your advanture with Go, you’re probably attracted by Go’s support of concurrency. That’s the main selling point of this language. If you know some Go, you probably tell your friends that Go’s model of concurrecy is based on CSP (Communicating Sequential Processes). But how does it look under the hood? Does it use threads, green threads? If someone asked you to explain it how does it look from an OS perspective, what would you say?
Simple but handy Formatting time in Go is a very interesting topic but let’s focus on a particular case: a popular TIMESTAMP format used in MySQL: ‘0000-00-00 00:00:00’. It turns out that if you want to use it in Go, you have to format time yourself. Luckily it’s a very easy job in Go. Let’s take current time: t := time.Now() fmt.Println(t) This will result in displaying time in the following format:
Build your network of containers There’s a lot of tutorials showing how to link containers using the docker run –link option, but the link flag is a depricated feature of Docker and may be eventually removed. I will show you how to link containers via docker network providing a template of Dockerfile for your Golang application, but the focus here is really on the process. It’s there already… Assuming you haven’t created any networks yet, executing docker network ls should list the default Docker networks:
Can you translate that to human language? A little over a week ago, Loïc Hoguin, the creator of Cowboy - a very popular web server built in Erlang, published an article about his experience of conviencing people to use Erlang, or rather their reaction when they see the Erlang’s syntax :) It inspired me to write this post. It’s hard to change humans habits (that’s how our brain works), so even if you give someone a super tool solving their problems but it will require changing their habits it might take longer than you expect.
Running indirectly… The Go Mobile project is marked as “experimental” and I guess it will take a couple of years until we’ll get some stable version. The way I’m going to show you how to run Go programs on Android is a bit tricky as it actually uses Termux which is an Android terminal emulator and Linux environment app. Technically we could install and run there many other languages, but let’s see how it’s getting on with Go.