fix golint warnings
This commit is contained in:
@@ -148,7 +148,6 @@ func createGoModFileIfNeed(dir string) {
|
||||
}
|
||||
tempPath = filepath.Dir(tempPath)
|
||||
if util.FileExists(filepath.Join(tempPath, goModeIdentifier)) {
|
||||
tempPath = filepath.Dir(tempPath)
|
||||
hasGoMod = true
|
||||
break
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ func genHandler(dir string, group spec.Group, route spec.Route) error {
|
||||
req = ""
|
||||
}
|
||||
var logicResponse string
|
||||
var writeResponse = "nil, nil"
|
||||
var writeResponse string
|
||||
var respWriter = `httpx.WriteJson(w, http.StatusOK, resp)`
|
||||
if len(route.ResponseType.Name) > 0 {
|
||||
logicResponse = "resp, err :="
|
||||
|
||||
@@ -34,7 +34,7 @@ func routeToFuncName(method, path string) string {
|
||||
path = strings.ReplaceAll(path, "-", "_")
|
||||
path = strings.ReplaceAll(path, ":", "With_")
|
||||
|
||||
return strings.ToLower(method)+strcase.ToCamel(path)
|
||||
return strings.ToLower(method) + strcase.ToCamel(path)
|
||||
}
|
||||
|
||||
func parseType(t string) string {
|
||||
|
||||
@@ -13,6 +13,10 @@ import (
|
||||
func writeProperty(writer io.Writer, member spec.Member, indent int, prefixForType func(string) string) error {
|
||||
writeIndent(writer, indent)
|
||||
ty, err := goTypeToTs(member.Type, prefixForType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
optionalTag := ""
|
||||
if member.IsOptional() || member.IsOmitempty() {
|
||||
optionalTag = "?"
|
||||
@@ -21,13 +25,14 @@ func writeProperty(writer io.Writer, member spec.Member, indent int, prefixForTy
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
comment := member.GetComment()
|
||||
if len(comment) > 0 {
|
||||
comment = strings.TrimPrefix(comment, "//")
|
||||
comment = " // " + strings.TrimSpace(comment)
|
||||
}
|
||||
if len(member.Docs) > 0 {
|
||||
_, err = fmt.Fprintf(writer, "%s\n", strings.Join(member.Docs, ""))
|
||||
fmt.Fprintf(writer, "%s\n", strings.Join(member.Docs, ""))
|
||||
writeIndent(writer, 1)
|
||||
}
|
||||
_, err = fmt.Fprintf(writer, "%s%s: %s%s\n", name, optionalTag, ty, comment)
|
||||
|
||||
@@ -28,6 +28,9 @@ func MaybeCreateFile(dir, subdir, file string) (fp *os.File, created bool, err e
|
||||
|
||||
func ClearAndOpenFile(fpath string) (*os.File, error) {
|
||||
f, err := os.OpenFile(fpath, os.O_WRONLY|os.O_TRUNC, 0600)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = f.WriteString("")
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user