go-zero/tools/modelctl/model/configtemplategen/gen.go
2020-07-29 17:12:04 +08:00

30 lines
495 B
Go

package configgen
import (
"fmt"
"os"
"zero/tools/modelctl/model"
"github.com/urfave/cli"
)
var (
configFileName = "config.json"
)
func ConfigCommand(_ *cli.Context) error {
_, err := os.Stat(configFileName)
if err == nil {
return nil
}
file, err := os.OpenFile(configFileName, os.O_CREATE|os.O_WRONLY, model.ModeDirPerm)
if err != nil {
return err
}
file.WriteString(configTemplate)
defer file.Close()
fmt.Println("config json template generate done ... ")
return nil
}