File size: 561 Bytes
7b9f3e3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | // addgenheader is a simple program that adds a DO NOT EDIT style
// comment at the top of a file. Because some generators do not do
// this, e.g. go-bindata
package main
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"strings"
)
func main() {
var buf bytes.Buffer
fmt.Fprintf(&buf, "// %v DO NOT EDIT\n", strings.TrimSpace(os.Args[2]))
fmt.Fprintf(&buf, "\n")
byts, err := ioutil.ReadFile(os.Args[1])
if err != nil {
panic(err)
}
fmt.Fprintf(&buf, "%s", byts)
if err := ioutil.WriteFile(os.Args[1], buf.Bytes(), 0666); err != nil {
panic(err)
}
}
|