Avatar (Fabio Alessandro Locati|Fale)'s blog

Parse multi-CSV files in Go

August 22, 2022

As it happens every year, I had to pull a lot of information from various financial intermediaries and convert them into the way the local tax system wanted them. For this reason, I created a Go program that does this modularly. Whenever I have a new financial intermediary, I create a new module that can read whatever format they create and returns a structured object in the form that the application expects.

Read More

gopass in Fedora

April 25, 2022

I started to use ZX2C4’s pass back in 2016 to manage my passwords. I liked the idea behind pass, but I found it too hackish. For this reason, I moved to gopass at the end of 2017 because it was a far more complete implementation of pass from my point of view. gopass is now part of my system, and I’m so used to it that it is hard for me to think about my workflows without gopass into them.

Read More

Inject DB connections in Golang gRPC API

March 21, 2022

One of the first issues that I had to solve when I started to use gRPC was how to inject a DB connection pool to the function handling the request. The DB connection injection is needed because creating a new SQL connection every time there is a new gRPC request (and tearing it down at the end) is a massive waste of resources. Also, this approach could limit the scalability of the API since the database probably has a limited number of connections it will accept.

Read More

gRPC-Gateway 2 in Fedora

February 22, 2022

gRPC is a very nice technology that allows the implementation of efficient APIs in a very efficient way. Thanks to gRPC and protobuf, you do not have to write much boilerplate code since the boilerplate code is generated automatically from the proto file. This works perfectly until both your client and server can perform gRPC calls. Luckily most of the languages have no issue with this. Still, the big exception is JavaScript (and other languages that will compile to JS, such as TypeScript) running in a browser.

Read More

CORS headers with gRPC-Gateway

July 28, 2021

A few years ago, I wrote a blog post on managing CORS headers with Negroni. Lately, I’ve created a new API server that needed to be accessible from the browser, but this time I used a different technology, more precisely gRPC-Gateway. Few months after I wrote that blog post, I stopped writing new REST services by hand. I did not rewrite all the services that used the old paradigm just because they needed a fix or a new feature, but for all new services, I moved to gRPC with gRPC-Gateway.

Read More

Sensible datetime scale for Gonum Plot

June 28, 2021

Few months ago I posted a library for sensible int scale for Gonum Plot. There is a similar package I’ve developed to handle timescales. The integer one, being based on a recursive function, works with any number scale. Differently, this one will only work well with a timescale between 2 days and a couple of years. Extending it is not hard since it’s enough to add additional case statements in the switch, but I’ve not found use-cases for different timeframes so far.

Read More

Sensible integer scale for Gonum Plot

January 20, 2021

Over the years, I found myself multiple times using Gonum Plot. I do find it as a very good and easy to use plotting tool for Go. The problem I found myself, over and over, dealing with is the tickers scale. If you know before-hand the values that can be expected to be created by the application, it is very straightforward, but the majority of times, this is not the case.

Read More

Google Cloud Snapshot Cleaner v0.2.0

September 22, 2019

Last week, in a previous article, I’ve introduced you to gcsc (Google Cloud Snapshot Cleaner). I’ve just released the version 0.2.0 of it, and it has a lot of clean-ups done, both in the code and the user experience. There are also some new features, but the one I’m more satisfied with, is the introduction of the http subcommand, to expose an HTTP server. The webserver will listen to any URI and Methods, and the request will trigger the snapshot clean-up.

Read More

Google Cloud Snapshot Cleaner v0.1.0

September 16, 2019

I’ve just tagged the first version (0.1.0) of gcsc (Google Cloud Snapshot Cleaner). The idea behind this small software is to create a more flexible way to keep the Google Cloud Disks Snapshots tidy. Google Cloud does provide a very nice way to automatically snapshot your disks, leveraging the resource policies. This is very nice, since it allows you to be sure that the Google Cloud always and reliably snapshots your disks.

Read More

GoLang vanity urls on AWS Lambda

March 21, 2019

After the article on the reasons to use vanity URLs in Go and the one about how to implement a lightweight vanity URLs provider, I’d like to share with you how you can leverage AWS Lambda to implement a vanity URLs provider. The first thing we will need is to import the github.com/aws/aws-lambda-go package. This package will provide us with the needed functions to easily integrate our Go code with AWS Lambda.

Read More
Older