dwarf/op: change generated comment header (#3288)

Change generated comment header for opcodes.go to match Go regexp:
```
^// Code generated .* DO NOT EDIT\.$
```

Fix panic in gen-opcodes.go if no args provided.
This commit is contained in:
Oleksandr Redko 2023-02-25 15:12:12 +02:00 committed by GitHub
parent 37e44bf603
commit d71b3aa6a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

@ -1,4 +1,5 @@
// This script generates pkg/dwarf/op/opcodes.go from pkg/dwarf/op/opcodes.txt
//go:build ignore
// +build ignore
package main
@ -19,7 +20,17 @@ type Opcode struct {
Func string
}
func usage() {
os.Stderr.WriteString("gen-opcodes <opcodes-table-path> <opcodes-destination-path>\n\n")
os.Stderr.WriteString("Generates Go file <opcodes-destination-path> from the table file <opcodes-table-path>.\n\n")
os.Exit(1)
}
func main() {
if len(os.Args) != 3 {
usage()
}
fh, err := os.Open(os.Args[1])
if err != nil {
log.Fatal(err)
@ -52,8 +63,9 @@ func main() {
var buf bytes.Buffer
fmt.Fprintf(&buf, `// THIS FILE IS AUTOGENERATED, EDIT opcodes.table INSTEAD
fmt.Fprintf(&buf, `// Code generated by gen-opcodes. DO NOT EDIT.
// Edit opcodes.table instead.
package op
`)

@ -1,4 +1,5 @@
// THIS FILE IS AUTOGENERATED, EDIT opcodes.table INSTEAD
// Code generated by gen-opcodes. DO NOT EDIT.
// Edit opcodes.table instead.
package op