Should I commit generated Go code?

Featured image for sharing metadata for article

I've recently had the conversation about whether go:generate'd code should be committed, to which I steered towards "no".

Coming from a Java background, I wouldn't commit generated files, instead let the build tool generate + package up the code into the built artefact.

This makes it easier as we get a freshly generated version each time, as well as needing to ignore code reviewing files generated by the tooling.

As I'm still new to the Go world, I forgot that Go doesn't distribute a built package, only source packages, which StackOverflow helped reinforce.

Therefore the answer is yes we do want to commit the code, so folks using the package can still interact with it, instead of needing to run the generation on their side, too.

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

#blogumentation #go.

Also on:

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.