mirror of
https://github.com/opbnq-q/nto-cli.git
synced 2025-12-06 16:20:34 +07:00
fix
This commit is contained in:
@@ -21,7 +21,7 @@ func FindFrontendPath() string {
|
||||
currentPath = filepath.Clean(dir)
|
||||
}
|
||||
|
||||
if len(dirs) < 2 || dirs[len(dirs)-2]+"/"+dirs[len(dirs)-1] != "frontend/src" {
|
||||
if len(dirs) < 2 || dirs[len(dirs)-2] + "/" + dirs[len(dirs)-1] != "frontend/src" {
|
||||
panic(errors.New("You're not in frontend/src"))
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,10 @@ func GetStructFields(file *os.File, structName string) []entities.Field {
|
||||
bracketsCount += strings.Count(line, "{")
|
||||
bracketsCount -= strings.Count(line, "}")
|
||||
line = strings.TrimSpace(line)
|
||||
newField := SplitStructField(line)
|
||||
newField, err := SplitStructField(line)
|
||||
if err != nil {
|
||||
return structFields
|
||||
}
|
||||
if newField != nil {
|
||||
structFields = append(structFields, *newField)
|
||||
}
|
||||
@@ -34,6 +37,5 @@ func GetStructFields(file *os.File, structName string) []entities.Field {
|
||||
if err := scanner.Err(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return structFields
|
||||
}
|
||||
@@ -1,15 +1,19 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"nto_cli/entities"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/structtag"
|
||||
)
|
||||
|
||||
func SplitStructField(field string) *entities.Field {
|
||||
if strings.Contains(field, "type") {
|
||||
return nil
|
||||
func SplitStructField(field string) (*entities.Field, error) {
|
||||
if strings.Contains(field, "type") {
|
||||
return nil, nil
|
||||
}
|
||||
if len(strings.TrimSpace(field)) < 2 {
|
||||
return nil, errors.New("End")
|
||||
}
|
||||
startBacktip := strings.Index(field, "`")
|
||||
endBacktip := -1
|
||||
@@ -42,9 +46,6 @@ func SplitStructField(field string) *entities.Field {
|
||||
|
||||
data := SplitBySingleSpace(field)
|
||||
|
||||
if len(data) < 2 {
|
||||
return nil
|
||||
}
|
||||
|
||||
name := data[0]
|
||||
dataType := data[1]
|
||||
@@ -52,5 +53,5 @@ func SplitStructField(field string) *entities.Field {
|
||||
Medatada: metadata,
|
||||
Type: dataType,
|
||||
Name: name,
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user