I’ve gone through the Golang tutorial once before but in the last month or so, I fully dove into it. I started by writing a simple hello world web application. I found the implementation of the webserver so neat that most of the uses I’d have for a framework is redundant. The in-built libraries already take care of handling most of the use-cases I have. I did a couple of views and a couple of templates. It seems to be working well.
As someone coming from Python, I keep tripping over types. I started my professional career with PHP and then moved to Python. Both of these languages aren’t very strongly typed by default. So it’s been fun to find errors and fix them. I learn more and more that I can’t be lazy.
The other thing that’s tripped me over in go is the use of tab vs spaces. Python’s standard has been my second nature for years, so it’s fun to find out that’s not how you do things in Go. I’ve downloaded vim-go and that’s helped make most of it second nature.
All of this started in a fun way. I wrote a tiny flask app to try out kubernetes on Google Cloud. It’s a simple hello world app with some templates. I’ve figured out some k8s basics and now I see why having one binary helps. The next step in that learning process is to plug in my Go binary rather that copy in multiple files.
I’ve played around with the date libraries in Go now, and jeez, that’s a fun one 🙂 I’m used to specifying a specific format. The golang method is to tell you to specify the layout with a particular date instead. That took me quite a long time to figure out. I’ll admit, it’s definitely easier, but damn, it tripped me over for a while since I couldn’t believe what I was seeing.
One of the things I’ve done quite a lot is write web scrapers. I used colly briefly to do some scraping. It’s a very cool API. I did some decent scraping. It was quite easy to write. The bit I found amusing is that I found a bug in a dependent library and sent in a pull request for a fix.
I didn’t have to wait for it to be merged. I could compile my binary with my fixes myself. Of course, the side effect is every time one of my dependencies have a security bug fixed, I have to send a bug fix myself. That kinda sucks, but in the brave new world of containers, that’s the sort of thing I expect to happen.
This tiny experiment is slowly increasing in scope as I figure out what’s the next bit of new knowledge I need to gain. My current goal is to replace my python hello world web application in my kubernetes cluster with a golang one.
At some point in this process, I can also inject figuring out multi-stage builds. That should make the process of pushing out a new build to my hello-world app easier.
The other thing I’m thinking of is converting the salary converter backend to golang. If it works well, I might move it out to be hosted on a Kubernetes cluster rather than on a full-sized server. That should help split out some of the applications I run to be hosted in a shared but highly-available clusters that I don’t have to manage uptime.
Leave a Reply