---
title: "Engineering nits: Generating code faster"
description: "incident.io cut a Go code-generation step from about 16 seconds to under half a second (97% faster) by adding commonly used imports directly to the generator's template."
url: "https://swe.quest/articles/engineering-nits-generating-code-faster-1820d3fbfc60303a"
canonical: "https://incident.io/blog/codegen-faster"
source: "incident.io"
published: "2023-12-11"
difficulty: "medium"
kind: "Case study"
reading_minutes: 5
tags: ["go","developer-productivity","performance","build-systems"]
---

# Engineering nits: Generating code faster

A post on [incident.io](https://swe.quest/sources/incident-io.md), published 2023-12-11, 5 min read, Case study. Original: [https://incident.io/blog/codegen-faster](https://incident.io/blog/codegen-faster)

## Summary

incident.io cut a Go code-generation step from about 16 seconds to under half a second (97% faster) by adding commonly used imports directly to the generator's template. The bottleneck was goimports resolving missing imports, which requires scanning every package in the module and its dependencies, repeated hundreds of times. Removing unused imports is cheap because it only inspects a single file, so over-including imports (with the list built via \`go list\`) leaves goimports little to resolve. The roughly 20-line change saves about 3 engineer-hours per week for a team of around 20.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Go](https://swe.quest/tags/go.md) (Languages)
- [Developer productivity](https://swe.quest/tags/developer-productivity.md) (Engineering practices)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Build systems](https://swe.quest/tags/build-systems.md) (Engineering practices)

## Prerequisites

- Go code generation ([easy posts on Go](https://swe.quest/tags/go.md?difficulty=easy))
- go generate

## Keywords

goimports, go generate, Gomega, gstruct, go/parser, go list

## Related posts

- [Debugging Go compiler performance in a large codebase](https://swe.quest/articles/debugging-go-compiler-performance-in-a-large-codebase-46b7968c79fa2123.md): incident.io · 2024-01-15 · Medium · 6 min read · Go, Build systems, Developer productivity, Performance engineering
  incident.io sped up builds of its Go monolith by tracing the compiler with \`go build -debug-trace\` and viewing the output in Perfetto.
- [DevEx matters for coding agents, too](https://swe.quest/articles/devex-matters-for-coding-agents-too-3cf5bcfa910d65e5.md): incident.io · 2025-12-19 · Medium · 11 min read · Developer productivity, TypeScript, Build systems, AI for coding, Developer tools
  incident.io cut its typical lint-plus-compile feedback loop from over 90 seconds to under 10, arguing that fast toolchains matter even more when AI coding agents generate code faster than slow tools can validate it.
- [How we reduced the size of our Agent Go binaries by up to 77%](https://swe.quest/articles/how-we-reduced-the-size-of-our-agent-go-binaries-by-up-to-77-01b71ba25e3ec4b1.md): Datadog Engineering · 2026-02-18 · Medium · 14 min read · Go, Build systems, Compilers, Performance engineering
  Datadog cut its Agent's Go binary sizes by up to 77% between versions 7.60.0 and 7.68.0 without removing features.
- [Tracking developer build times to decide if the M3 MacBook is worth upgrading](https://swe.quest/articles/tracking-developer-build-times-to-decide-if-the-m3-macbook-is-worth-upgrading-203da83e8808415f.md): incident.io · 2023-12-19 · Medium · 17 min read · Developer productivity, Go, Hardware, Performance engineering, Build systems
  incident.io built a custom Go hot-reloader that records build telemetry (platform, memory, power source, Go build stages, triggering files) from developer MacBooks and pipes it through Fivetran into BigQuery.
- [The quest for the five minute deploy](https://swe.quest/articles/the-quest-for-the-five-minute-deploy-9b91763fbfd58020.md): incident.io · 2025-07-22 · Medium · 9 min read · CI/CD, Go, Build systems, Caching, Developer productivity
  incident.io cut CI/CD times by moving from a hosted provider, where a cold Go build cache made compiling 15,000+ tests across 350+ packages the bottleneck, to Buildkite running on three self-hosted 48-vCPU servers.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
