func writeTemplate(fileName string, tmpl *template.Template, data interface{}) {
	buf := &bytes.Buffer{}
	err := tmpl.Execute(buf, data)
	if err != nil {
		log.Fatal(err)
	}

	formatted, err := format.Source(buf.Bytes())
	if err != nil {
		log.Fatal(err)
	}

	fd, err := os.Create(fileName)
	if err != nil {
		log.Fatal(err)
	}
	defer fd.Close()

	fd.Write(formatted)
}
// writeTemplate writes the given template to the given file, with the given
// data. Templates are assumed to be generating go source files, so they
// are formatted as well.
writeTemplate writes the given template to the given file, with the given
data. Templates are assumed to be generating go source files, so they
are formatted as well.
// writeTemplate writes the given template to the given file with the given // data . Templates are assumed to be generating go source files so they // are formatted as well .
func writeTemplate(fileName string, tmpl *template.Template, data interface{}) {
	buf := &bytes.Buffer{}
	err := tmpl.Execute(buf, data)
	if err != nil {
		log.Fatal(err)
	}
	formatted, err := format.Source(buf.Bytes())
	if err != nil {
		log.Fatal(err)
	}
	fd, err := os.Create(fileName)
	if err != nil {
		log.Fatal(err)
	}
	defer fd.Close()
	fd.Write(formatted)
}
func writeTemplate ( fileName string , tmpl * template . Template , data interface { } ) { buf := & bytes . Buffer { } err := tmpl . Execute ( buf , data ) if err != nil { log . Fatal ( err ) } formatted , err := format . Source ( buf . Bytes ( ) ) if err != nil { log . Fatal ( err ) } fd , err := os . Create ( fileName ) if err != nil { log . Fatal ( err ) } defer fd . Close ( ) fd . Write ( formatted ) }
writeTemplate writes the given template to the given file, with the given
data.
writeTemplate writes the given template to the given file with the given data .