Write a code generator or scaffolding tool that outputs valid Go source files.
Build a struct, interface, or function definition programmatically instead of using text templates.
Generate boilerplate Go code from a data model or schema at build time.
| dave/jennifer | go-oauth2/oauth2 | opencontainers/runtime-spec | |
|---|---|---|---|
| Stars | 3,617 | 3,615 | 3,621 |
| Language | Go | Go | Go |
| Setup difficulty | easy | moderate | hard |
| Complexity | 2/5 | 3/5 | 4/5 |
| Audience | developer | developer | developer |
Figures from each repo's GitHub metadata at analysis time.
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.
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.
Mainly Go. The stack also includes Go.
Setup difficulty is rated easy, with roughly 5min to a first successful run.
Mainly developer.
This repo across BitVibe Labs
Verify against the repo before relying on details.