• Stars
    star
    50
  • Rank 557,236 (Top 12 %)
  • Language
    Go
  • License
    Other
  • Created over 9 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The package underlying gen: type-driven code generation for Go

##What’s this?

Typewriter is a package to enable pluggable, type-driven codegen for Go. The envisioned use case is for generics-like functionality. This package forms the underpinning of gen.

Usage is analogous to how codecs work with Go’s image package, or database drivers in the sql package.

import (
    // main package
	“github.com/clipperhouse/typewriter”
	
	// any number of typewriters 
	_ “github.com/clipperhouse/set”
	_ “github.com/clipperhouse/linkedlist”
)

func main() {
	app, err := typewriter.NewApp(”+gen”)
	if err != nil {
		panic(err)
	}

	app.WriteAll()
}

Individual typewriters register themselves to the “parent” package via their init() functions. Have a look at one of the above typewriters to get an idea.