explaingit

dave/jennifer

Analysis updated 2026-05-18

3,617GoAudience · developerComplexity · 2/5Setup · easy

TLDR

Jennifer is a Go library for writing programs that generate other Go source code, building it up with chained function calls instead of raw text strings.

Mindmap

mindmap
  root((Jennifer))
    What it does
      Generates Go source code
      Fluent API
    Tech stack
      Go
    Use cases
      Code generators
      Scaffolding tools
      Build time codegen
    Audience
      Go developers
      Tool builders

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Write a code generator or scaffolding tool that outputs valid Go source files.

USE CASE 2

Build a struct, interface, or function definition programmatically instead of using text templates.

USE CASE 3

Generate boilerplate Go code from a data model or schema at build time.

What is it built with?

Go

How does it compare?

dave/jennifergo-oauth2/oauth2opencontainers/runtime-spec
Stars3,6173,6153,621
LanguageGoGoGo
Setup difficultyeasymoderatehard
Complexity2/53/54/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

In plain English

Jennifer is a library for the Go programming language that lets you write programs which generate other Go programs. Instead of building up source code as raw text strings, you use Jennifer's functions to construct code piece by piece, and the library assembles it into valid, properly formatted Go source files for you. The core idea is that you build a "file" object in your program, add functions, variables, imports, and logic to it using Jennifer's fluent API, then ask Jennifer to render the result. For example, to produce a file with a main function that prints a message, you call a series of chained methods like Func, Id, Block, and Qual. When you print the file, out comes clean, runnable Go source code. Jennifer handles all the import statements automatically, and if two imported packages happen to share a name, it renames one of them to avoid conflicts. The library covers the full range of Go syntax: identifiers, operators, keywords, control flow (if/for/switch/select), collections (maps, slices, structs), literals (numbers, strings, booleans), type definitions, interfaces, generics, and comments. There are helper methods for common patterns like multiple return values, variadic arguments, and raw code blocks for cases where the structured API is not the right fit. Almost every Go construct you can write by hand can be produced through Jennifer. The intended users are Go developers writing code generators, scaffolding tools, or anything that needs to programmatically emit Go source. The library was stable enough that it has been used to generate parts of itself. For quick inspection and testing during development, you can print any expression or file to the console using Go's fmt package. For production use, Jennifer provides a Render method that writes to any io.Writer and a Save method that writes directly to a file on disk. Installation is a single go get command, and the documentation includes a large set of runnable examples covering every feature.

Copy-paste prompts

Prompt 1
Show me how to use Jennifer to generate a Go file with a main function that prints hello world.
Prompt 2
Explain how Jennifer automatically handles import statements and naming conflicts.
Prompt 3
Help me write a Jennifer code generator that produces a Go struct from a list of field names.
Prompt 4
What is the difference between using fmt to print a Jennifer statement and using File.Render?

Frequently asked questions

What is jennifer?

Jennifer is a Go library for writing programs that generate other Go source code, building it up with chained function calls instead of raw text strings.

What language is jennifer written in?

Mainly Go. The stack also includes Go.

How hard is jennifer to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is jennifer for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.