go-generate-example/gen.go
Vincent Batts 8402d724a9
basic generation
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2018-06-27 11:39:46 -04:00

30 lines
361 B
Go

// +build ignore
package main
import (
"flag"
"io/ioutil"
"log"
"os"
)
var flOutput = flag.String("o", "", "output file to write")
func main() {
flag.Parse()
err := ioutil.WriteFile(*flOutput, []byte(source), os.FileMode(0644))
if err != nil {
log.Fatal(err)
}
}
var source = `
package main
import "fmt"
func foo() {
fmt.Println("brrnnt")
}
`