Skip to content
/ goat Public

Easily generate golang source from templates.

License

Notifications You must be signed in to change notification settings

fluhus/goat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Goat

go get github.com/fluhus/goat

Goat (short for go-templates) allows one to easily generate golang source from templates using go generate.

Example

mypackage.go

package mypackage

//go:generate goat -i types.got -o types.go -d [8,16,32,64]

// ...

types.got

package mypackage

{{range . -}}
type counter{{.}} map[int{{.}}]int
{{end}}

types.go (output)

// ***** DO NOT EDIT THIS FILE MANUALLY. *****
//
// This file was auto-generated using goat.
//
// goat: https://www.github.com/fluhus/goat

package mypackage

type counter8 map[int8]int
type counter16 map[int16]int
type counter32 map[int32]int
type counter64 map[int64]int

Usage

go run github.com/fluhus/goat [-i INPUT_FILE] [-o OUTPUT_FILE] [-d DATA] [-nh] [-nf]

  -d string
    	JSON-encoded data for the template.
  -i string
    	Path to input template file. If omitted, reads from stdin.
  -nf
    	Don't run gofmt on the result.
  -nh
    	Don't add a header to the output file.
  -o string
    	Path to output go file. If omitted, writes to stdout.

Releases

No releases published

Languages