gent

command module
v0.0.0-...-118bf68 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2021 License: MIT Imports: 8 Imported by: 0

README

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.

Documentation

Overview

Command goat generates go source from a given template.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL