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.
Be pragmatic I’m currently looking for a job and I found a weird pattern about Docker questions. Once I confirmed I had worked with Docker, no more questions were asked… Lucky me you may think, but that made me wonder why is that. Working with Docker is failry easy. Docker simplified the process of working with isolated resources providing a high-level API to run processes in isolation, but does it not deserve to a little chat about it during an interview?
Performance and modularity The general tendency in the web development world is to increase reusibility of completed web projects which eventually leads into a faster delivery of new products, updates, etc. That’s what’s always been obvious to experienced programmers when desiging software (modularity, loosly coupled classes, etc) is being supported from every possible angle (tooling, frameworks, repositories, even project planning) these days. Well, it’s good :) The second important feature of web frameworks which has always been and always will be in a focus of attension is performance.
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.
Let’s start listening… …listening for incoming socket connections. This is the very first thing that every server should do and to avoid potential problems with firewalls/proxies, let’s use the standard port 80. So, what else should our WebSocket server be able to do? respond to the handshake request (GET) receive and send messages extract frames keep track of clients respond to Pings and Pongs
Forget about frameworks for now… There’s a lot of frameworks that support WebSockets, but the purpose of every framework is to speed up the process of building products by hiding all low level details underneath, the details which I believe are important to know (=understand). You probably know that WebSockets allow you to establish real time communication between a webserver and its clients and what’s cool about it, is you can get a response without a need to request it (explicitly).
Does the place matter? Unless there’s a security guard asking you to empty your pockets, leave your mobile phone at the reception, the place does not really matter. Ask yourself these two simple questions: do you really know what other people do in the office? If you’re a manager you’re probably have your own office and if even if you don’t you probably would not stare at someone’s monitor (they will minimize the window very quickly anyway ;) ) Having your staff in the office gives you only an illusion of controlling their work.
Why am I blogging? I just want to share my ideas, knowledge and experience with you and I hope you’ll find it interesting. I’m a pragmatist, so I will do my best to make my posts useful but I will also touch very theoretical topics. I don’t like very long posts myself (I think most of us just scroll down to get to the point :)), so I will try to keep them short.