Introduction PostgreSQL’s ON CONFLICT clause is a useful construct that allows you to handle cases where an insertion may violate a uniqueness constraint. It is not standard SQL syntax, but an extension, like SQLite’s INSERT OR REPLACE . Let’s say we have a table named tasks like this: create table if not exists tasks ( account_id integer not null , task_name text not null ,…
Introduction At some point in the recent past; I needed to port the integration tests of a Go service using PostgreSQL to MongoDB. I was surprised by the lack of resources for loading test fixtures, so I decided to document my approach here. For PostgreSQL, we use go-testfixtures to describe our test data as .yml files, which (naturally) does not support MongoDB. I wanted a similar approach for…
Introduction Ok, this will be a short one. In the previous posts ; we tried to reduce endpoint handler boilerplate in Go by imitating the Axum magic functions. This post is not about that, but I think one of the tricks we pulled there may have another use case. If you’ll recall, we iterated through two separate solutions to the endpoint problem, where in the latter one we used struct fields…
Introduction In the first part of this blog post, we tried to replicate the magic of axum in Go. In the end, we had endpoint handlers that looked like this: func createUser ( l Logger , payload JSON [ CreateUser ]) ( response JSON [ User ], _ error ) { response . V = User { ID : 1337 , Username : payload . V . Username } l . Info ( 'created' , 'user' , payload . V . Username ) return } I recommend…
Part 2 is out! Introduction Rustaceans using the axum framework can employ the “magic function” pattern to write very descriptive handler functions with little boilerplate. Can we imitate it in Go? Let’s find out! Why, though? ¯\_(ツ)_/¯ Axum’s magic functions axum is a Rust web framework that focuses on ergonomics and modularity. One particularly impressive feature of axum…
35-year-old staff software engineer serving code the old-fashioned way. Currently working in Picus Security . You can contact me at: LinkedIn | GitHub This blog mostly contains my opinionated ramblings and personal experiments led by boredom while serving no practical purposes.