Skip to content

Commit

Permalink
Check that exec and model filenames end in *.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathew Byrne committed Jul 9, 2018
1 parent 6d38f77 commit fc43a92
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions codegen/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,21 @@ func (c *PackageConfig) Check() error {
if strings.ContainsAny(c.Package, "./\\") {
return fmt.Errorf("package should be the output package name only, do not include the output filename")
}
if c.Filename != "" && !strings.HasSuffix(c.Filename, ".go") {
return fmt.Errorf("filename should be path to a go source file")
}
return nil
}

func (cfg *Config) Check() error {
if err := cfg.Models.Check(); err != nil {
return fmt.Errorf("config: %s", err.Error())
return errors.Wrap(err, "config.models")
}
if err := cfg.Exec.Check(); err != nil {
return fmt.Errorf("config: %s", err.Error())
return errors.Wrap(err, "config.exec")
}
if err := cfg.Model.Check(); err != nil {
return fmt.Errorf("config: %s", err.Error())
return errors.Wrap(err, "config.model")
}
return nil
}
Expand Down

0 comments on commit fc43a92

Please sign in to comment.