Esempio n. 1
0
func (a *appGenerator) generateMain(app *genApp) error {
	buf := bytes.NewBuffer(nil)
	if err := mainTemplate.Execute(buf, app); err != nil {
		return err
	}
	log.Println("rendered main template:", "server."+app.AppName)
	return writeToFile(filepath.Join(a.Target, "cmd", swag.ToCommandName(app.AppName+"Server")), "main", buf.Bytes())
}
Esempio n. 2
0
func (a *appGenerator) generateConfigureAPI(app *genApp) error {
	pth := filepath.Join(a.Target, "cmd", swag.ToCommandName(app.AppName+"Server"))
	nm := "Configure" + app.AppName
	if fileExists(pth, nm) {
		log.Println("skipped (already exists) configure api template:", app.Package+".Configure"+app.AppName)
		return nil
	}

	buf := bytes.NewBuffer(nil)
	if err := configureAPITemplate.Execute(buf, app); err != nil {
		return err
	}
	log.Println("rendered configure api template:", app.Package+".Configure"+app.AppName)
	return writeToFileIfNotExist(pth, nm, buf.Bytes())
}