Эх сурвалжийг харах

chore: remove blank lines (#2117)

* chore: remove blank lines

* chore: refactor
Kevin Wan 2 жил өмнө
parent
commit
97a171441d

+ 0 - 1
core/utils/version.go

@@ -37,7 +37,6 @@ func CompareVersions(v1, op, v2 string) bool {
 func compare(v1, v2 string) int {
 	v1, v2 = replacer.Replace(v1), replacer.Replace(v2)
 	fields1, fields2 := strings.Split(v1, "."), strings.Split(v2, ".")
-
 	ver1, ver2 := strsToInts(fields1), strsToInts(fields2)
 	ver1len, ver2len := len(ver1), len(ver2)
 	shorter := mathx.MinInt(ver1len, ver2len)

+ 3 - 0
tools/goctl/api/docgen/doc.go

@@ -21,11 +21,13 @@ func genDoc(api *spec.ApiSpec, dir, filename string) error {
 	if len(api.Service.Routes()) == 0 {
 		return nil
 	}
+
 	fp, _, err := util.MaybeCreateFile(dir, "", filename)
 	if err != nil {
 		return err
 	}
 	defer fp.Close()
+
 	var builder strings.Builder
 	for index, route := range api.Service.Routes() {
 		routeComment := route.JoinedDoc()
@@ -61,6 +63,7 @@ func genDoc(api *spec.ApiSpec, dir, filename string) error {
 
 		builder.Write(tmplBytes.Bytes())
 	}
+
 	_, err = fp.WriteString(strings.Replace(builder.String(), """, `"`, -1))
 	return err
 }

+ 1 - 1
tools/goctl/model/cmd.go

@@ -83,7 +83,7 @@ func init() {
 
 	mongoCmd.Flags().StringSliceVarP(&mongo.VarStringSliceType, "type", "t", nil, "Specified model type name")
 	mongoCmd.Flags().BoolVarP(&mongo.VarBoolCache, "cache", "c", false, "Generate code with cache [optional]")
-	mongoCmd.Flags().BoolVarP(&mongo.VarBoolEasy, "easy", "e", false, "Generate code with Auto generated CollectionName for easy declare [optional]")
+	mongoCmd.Flags().BoolVarP(&mongo.VarBoolEasy, "easy", "e", false, "Generate code with auto generated CollectionName for easy declare [optional]")
 	mongoCmd.Flags().StringVarP(&mongo.VarStringDir, "dir", "d", "", "The target dir")
 	mongoCmd.Flags().StringVar(&mongo.VarStringStyle, "style", "", "The file naming format, see [https://github.com/zeromicro/go-zero/tree/master/tools/goctl/config/readme.md]")
 	mongoCmd.Flags().StringVar(&mongo.VarStringHome, "home", "", "The goctl home path of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority")

+ 2 - 4
tools/goctl/model/mongo/template/model_custom.tpl

@@ -6,7 +6,7 @@ package model
 ){{else}}import "github.com/zeromicro/go-zero/core/stores/mon"{{end}}
 
 {{if .Easy}}
-    const {{.Type}}CollectionName = "{{.snakeType}}"
+const {{.Type}}CollectionName = "{{.snakeType}}"
 {{end}}
 
 var _ {{.Type}}Model = (*custom{{.Type}}Model)(nil)
@@ -30,11 +30,9 @@ type (
     return &custom{{.Type}}Model{
         default{{.Type}}Model: newDefault{{.Type}}Model(conn),
     }
-}
-{{else}}func New{{.Type}}Model(url, db, collection string{{if .Cache}}, c cache.CacheConf{{end}}) {{.Type}}Model {
+}{{else}}func New{{.Type}}Model(url, db, collection string{{if .Cache}}, c cache.CacheConf{{end}}) {{.Type}}Model {
     conn := {{if .Cache}}monc{{else}}mon{{end}}.MustNewModel(url, db, collection{{if .Cache}}, c{{end}})
     return &custom{{.Type}}Model{
         default{{.Type}}Model: newDefault{{.Type}}Model(conn),
     }
 }{{end}}
-