Go metaprogramming

Write the pattern.
Generate the rest.

Metago turns Go directives and reusable templates into ordinary, formatted Go code—without reflection or runtime magic.

01

Annotate

Attach concise //mgo: directives directly to Go symbols.

02

Template

Use familiar Go templates with rich type and package metadata.

03

Compile

Generate normal Go sidecars or inline code, ready for the compiler.

A tiny compiler before your compiler

Metago scans Go packages and *.metago templates, resolves directive targets, and writes formatted Go. Generated files stay transparent: inspect them, test them, and compile them with the normal Go toolchain.

//mgo:gen stringer
type Status int
{{ define "stringer" }}
func (v {{ name . }}) String() string { return string(v) }
{{ end }}