Minor cleanup to client/gen.go
This commit is contained in:
parent
622c90c82c
commit
d413f67302
|
@ -26,17 +26,26 @@ const (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
flagOut = flag.String("out", "targettype.go", "out file")
|
flagOut = flag.String("out", "targettype.go", "out file")
|
||||||
|
|
||||||
typeAsStringRE = regexp.MustCompile(`type_as_string\s+==\s+"([^"]+)"`)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if err := run(); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var typeAsStringRE = regexp.MustCompile(`type_as_string\s+==\s+"([^"]+)"`)
|
||||||
|
|
||||||
|
// run executes the generator.
|
||||||
|
func run() error {
|
||||||
|
var err error
|
||||||
|
|
||||||
// grab source
|
// grab source
|
||||||
buf, err := grab(devtoolsHTTPClientCc)
|
buf, err := grab(devtoolsHTTPClientCc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// find names
|
// find names
|
||||||
|
@ -55,15 +64,11 @@ func main() {
|
||||||
decodeVals += fmt.Sprintf("case %s:\n*tt=%s\n", name, name)
|
decodeVals += fmt.Sprintf("case %s:\n*tt=%s\n", name, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ioutil.WriteFile(*flagOut, []byte(fmt.Sprintf(targetTypeSrc, constVals, decodeVals)), 0644)
|
if err = ioutil.WriteFile(*flagOut, []byte(fmt.Sprintf(targetTypeSrc, constVals, decodeVals)), 0644); err != nil {
|
||||||
if err != nil {
|
return err
|
||||||
log.Fatal(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = exec.Command("gofmt", "-w", "-s", *flagOut).Run()
|
return exec.Command("gofmt", "-w", "-s", *flagOut).Run()
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// grab retrieves a file from the chromium source code.
|
// grab retrieves a file from the chromium source code.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user