go-generate-example/gen.go

31 lines
361 B
Go
Raw Normal View History

// +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")
}
`