ex)create “ex-app”
internal/recipe/local/exapp
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",
},
},
}
}
other templateMethod : toCamel, toLowerCamel (ex. [[.AppName | ToLoewerCamel]]) |
interal/recipe/local/templates.go
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
}
$ gogener create exapp