123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package gogen
- import (
- "fmt"
- "strconv"
- "git.i2edu.net/i2/go-zero/tools/goctl/api/spec"
- "git.i2edu.net/i2/go-zero/tools/goctl/config"
- "git.i2edu.net/i2/go-zero/tools/goctl/util/format"
- )
- const (
- defaultPort = 8888
- etcDir = "etc"
- etcTemplate = `Name: {{.serviceName}}
- Host: {{.host}}
- Port: {{.port}}
- `
- )
- func genEtc(dir string, cfg *config.Config, api *spec.ApiSpec) error {
- filename, err := format.FileNamingFormat(cfg.NamingFormat, api.Service.Name)
- if err != nil {
- return err
- }
- service := api.Service
- host := "0.0.0.0"
- port := strconv.Itoa(defaultPort)
- return genFile(fileGenConfig{
- dir: dir,
- subdir: etcDir,
- filename: fmt.Sprintf("%s.yaml", filename),
- templateName: "etcTemplate",
- category: category,
- templateFile: etcTemplateFile,
- builtinTemplate: etcTemplate,
- data: map[string]string{
- "serviceName": service.Name,
- "host": host,
- "port": port,
- },
- })
- }
|