Code review comment

This commit is contained in:
Naveen Gogineni 2022-11-04 08:36:32 -04:00
parent f8a7cfe246
commit 45dc37629c

View File

@ -177,25 +177,28 @@ func runGenFlags(cCtx *cli.Context) error {
return err return err
} }
if !cCtx.IsSet("altsrc") { if cCtx.IsSet("altsrc") {
genTestTmpl, err := template.New("gen_test").Parse(TestTemplateString) return nil
if err != nil {
return err
}
genTestBuf := &bytes.Buffer{}
if err := genTestTmpl.Execute(genTestBuf, spec); err != nil {
return err
}
if err := os.WriteFile(cCtx.Path("generated-test-output"), genTestBuf.Bytes(), 0644); err != nil {
return err
}
if _, err := sh(cCtx.Context, cCtx.Path("goimports"), "-w", cCtx.Path("generated-test-output")); err != nil {
return err
}
} }
genTestTmpl, err := template.New("gen_test").Parse(TestTemplateString)
if err != nil {
return err
}
genTestBuf := &bytes.Buffer{}
if err := genTestTmpl.Execute(genTestBuf, spec); err != nil {
return err
}
if err := os.WriteFile(cCtx.Path("generated-test-output"), genTestBuf.Bytes(), 0644); err != nil {
return err
}
if _, err := sh(cCtx.Context, cCtx.Path("goimports"), "-w", cCtx.Path("generated-test-output")); err != nil {
return err
}
return nil return nil
} }