fix-break-line
This commit is contained in:
@@ -2,6 +2,7 @@ package ktgen
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/tal-tech/go-zero/core/lang"
|
"github.com/tal-tech/go-zero/core/lang"
|
||||||
"github.com/tal-tech/go-zero/tools/goctl/api/parser"
|
"github.com/tal-tech/go-zero/tools/goctl/api/parser"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
package ktgen
|
package ktgen
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/tal-tech/go-zero/tools/goctl/api/util"
|
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
|
"github.com/tal-tech/go-zero/tools/goctl/api/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
var funcsMap = template.FuncMap{
|
var funcsMap = template.FuncMap{
|
||||||
"lowCamelCase": lowCamelCase,
|
"lowCamelCase": lowCamelCase,
|
||||||
"pathToFuncName": pathToFuncName,
|
"pathToFuncName": pathToFuncName,
|
||||||
"parseType": parseType,
|
"parseType": parseType,
|
||||||
"add": add,
|
"add": add,
|
||||||
}
|
}
|
||||||
|
|
||||||
func lowCamelCase(s string) string {
|
func lowCamelCase(s string) string {
|
||||||
if len(s) < 1 {
|
if len(s) < 1 {
|
||||||
return ""
|
return ""
|
||||||
@@ -25,12 +28,13 @@ func pathToFuncName(path string) string {
|
|||||||
path = "/" + path
|
path = "/" + path
|
||||||
}
|
}
|
||||||
|
|
||||||
path = strings.Replace(path, "/", "_", -1)
|
path = strings.ReplaceAll(path, "/", "_")
|
||||||
path = strings.Replace(path, "-", "_", -1)
|
path = strings.ReplaceAll(path, "-", "_")
|
||||||
|
|
||||||
camel := util.ToCamelCase(path)
|
camel := util.ToCamelCase(path)
|
||||||
return util.ToLower(camel[:1]) + camel[1:]
|
return util.ToLower(camel[:1]) + camel[1:]
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseType(t string) string {
|
func parseType(t string) string {
|
||||||
t = strings.Replace(t, "*", "", -1)
|
t = strings.Replace(t, "*", "", -1)
|
||||||
if strings.HasPrefix(t, "[]") {
|
if strings.HasPrefix(t, "[]") {
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package ktgen
|
package ktgen
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/tal-tech/go-zero/core/logx"
|
|
||||||
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/iancoleman/strcase"
|
"github.com/iancoleman/strcase"
|
||||||
|
"github.com/tal-tech/go-zero/core/logx"
|
||||||
|
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
Reference in New Issue
Block a user