Factor3 (v0) - a code gen for configuring your Go app

Photo by Peter Herrmann on Unsplash I wrote a small toy for loading configuration easily from multiple sources. I was thinking a lot about it, even wrote a whole post. Here’s a link to it The Problem I wanted a 100% opinionated library that would let me define a Go struct with the expected values and let it generate code that loads configuration from multiple sources, simultaneously: The default configuration will be defined in a yaml file The values in the config file can be overridden by environment variables, and those environment variables can be overridden by passing flags in the commandline....

January 8, 2024 · 3 min · Dror Nir

Why Code Generation?

Photo by Iñaki del Olmo on Unsplash Code Generation is a form of Metaprogramming From the early days of the C programming language, to today’s cutting edge languages, some sort of meta programming technique is used. By “meta programming”, I mean any form of programming that adds functionality to the code you write, without actually writing that extra functionality. According to Wikipedia: Metaprogramming […] means a program can be designed to read, generate, analyze or transform other programs, and even modify itself while running....

July 31, 2023 · 8 min · Dror Nir

A Declarative Config for Golang

A Declarative Configuration lib for Go I’m thinking about building a Go package (and CLI) to let me just declare a schema of a config, and use code generation on top of that to declare how I want to Marshal and Unmarshal it into anything that makes sense. I want to try to make a case in favor of writing it before I actually roll up my sleeves and write it....

July 25, 2023 · 9 min · Dror Nir