As a product manager by trade, I don’t need sit and learn programming languages as I’m not expected to site down and write code. But the engineering in me wants to keep building.
Looking at data is a big part of my day-to-day work. You might have a data analyst to help you with this, but the analysis of the data and understanding you get of your customer is not something you can delegate. Thus, most cases I take matter into my hands.
Now there is only so much SQL queries you can write and run daily. At some point in time you want to store these values and trend over time. Chances are you have system that will do the job for you, but when you don’t you take matters at hand.
Python was a go to choice, but I wanted to build a
cli tool that would allow me to run
cURL like commands to an
API and capture some of the timing metrics as well. At times I would have 100’s of URL’s that I did like to check.
I also wanted to pull
RUM data from our vendor tool for pages of my SaaS application and correlate that data that I pulled from the database.
I had Grafana and
MySQL set up to view this data, but I needed something that would run my queries,
cURL my API endpoints and pull data from 3rd party application into this
After talking to a few friends, I looked into
golang as a means to do whatever automation I needed to do at my end. One of the biggest reason to consider
golang was the concurrency – easy to understand and implement.
I have a full fledged system set up today that allows me to look into trends in my SaaS applications with multiple data sources contributing to these dashboards. Here are a few links I used to get myself started into golang.
Go by Example – https://gobyexample.com
Literally from basics. I read this just to get a hang on their syntax and how to structure code.
The Go+ language for engineering, STEM education, and data science – https://github.com/goplus/gop
Yet another library that cuts down the learning by focusing on the most basics of things. Really good library.
How to write go code – https://golang.org/doc/code
When you first start writing go code and everything is in a single file; it woks like magic. When you start separating your layers, is when you get into trouble. This tutorial form Google was one of the best to get me started and understanding how to structure my code.
SOLID Go Design by Dave Cheney – https://dave.cheney.net/2016/08/20/solid-go-design
Once you get a hang of things, follow Dave Cheney’s blog. This will get you started in golang design patters and most important concurrency.
How to create a CLI in golang with cobra – https://towardsdatascience.com/how-to-create-a-cli-in-golang-with-cobra-d729641c7177
I wanted to build a CLI tool and there is no better library then cobra and viper. I have no moved away from these libraries and build everything thats available in golang; but these libraries will get you started quickly and also help you understand how to build cli tolls and read settings from a config file.
Viper for config file settings – https://github.com/spf13/viper
Cobra for building a CLI tool – https://github.com/spf13/cobra
Lastly an example of golang CRUD using MySQL form scratch – https://www.golangprograms.com/example-of-golang-crud-using-mysql-from-scratch.html
This will give you a basic understanding on pushing data into a database.
It is always good to refer to codebases as well to get an understanding of how to structure your code or to simply see deeding patters. Some code bases I looked into were Kubernetes and Elastic’s Beats.