gogener

How to add local App

ex)create “ex-app”

  1. make directoryinternal/recipe/local/exapp
  2. cd exapp && touch app.go
package exapp

import (
	"path/filepath"

	"github.com/ryomak/gogener/internal/templater"
	"github.com/urfave/cli/v2"
)

func AppTmplFunc(c *cli.Context) *templater.AppTemplate {
	return &templater.AppTemplate{
		Name: "ex-app",
		Tmpls: []*templater.Templater{
			{sv
                Tmpl: `
                package main
                import (
                    "fmt"
                )

                func main() {
                    fmt.Println("hello [[.AppName]]")
                }
                `,
				Dir:  filepath.Join(""),
				Name: "main.go",
			},
		},
	}
}
  1. change interal/recipe/local/templates.go
    • add new AppTmplFunc
import(
	..
	+ "github.com/ryomak/gogener/internal/recipe/local/exapp"
)
var localMap = map[string]func(c *cli.Context) *templater.AppTemplate{
	"ryomak-app": ryomak.AppTmplFunc,
	+ "exapp": exapp.AppTmplFunc
}

  1. $ gogener create exapp