<commit_before>+++
author = ["<NAME>"]
date = "2015-12-08T08:00:00+00:00"
title = "Reducing boilerplate with go generate"
series = ["Advent 2015"]
+++

Go is an awesome language. It's simple, powerful, has great tooling and
many of us really enjoy using it every day. However, as it usually
happens with strongly typed languages, we write a good deal of
boilerplate to connect things around.

In this post we'll cover mostly three points:

1. Why can we build tools with Go that will help reduce boilerplate using code generation.
2. What are the building blocks for code generation in Go.
3. Where can we find examples of code generation tools to learn more.

# Why use code generation to reduce boilerplate?

Sometimes we try to reduce boilerplate by using reflection and filling
our projects with methods accepting `interface{}`. However, whenever a
method takes an `interface{}`, we are throwing our type safety out of<commit_msg>Changing the date to Dec 10th<commit_after>+++
author = ["<NAME>"]
date = "2015-12-10T08:00:00+00:00"
title = "Reducing boilerplate with go generate"
series = ["Advent 2015"]
+++

Go is an awesome language. It's simple, powerful, has great tooling and
many of us really enjoy using it every day. However, as it usually
happens with strongly typed languages, we write a good deal of
boilerplate to connect things around.

In this post we'll cover mostly three points:

1. Why can we build tools with Go that will help reduce boilerplate using code generation.
2. What are the building blocks for code generation in Go.
3. Where can we find examples of code generation tools to learn more.

# Why use code generation to reduce boilerplate?

Sometimes we try to reduce boilerplate by using reflection and filling
our projects with methods accepting `interface{}`. However, whenever a
method takes an `interface{}`, we are throwing our type safety out of
{'fraction_non_alphanumeric': 0.06581740976645435, 'fraction_numerical': 0.027600849256900213, 'mean_word_length': 4.6437125748503, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '135904', 'n_tokens_mistral': 542, 'n_tokens_neox': 483, 'n_words': 288}