diff --git a/cmd/kratos/internal/proto/add/add.go b/cmd/kratos/internal/proto/add/add.go index 4caafe932..c658aba27 100644 --- a/cmd/kratos/internal/proto/add/add.go +++ b/cmd/kratos/internal/proto/add/add.go @@ -21,6 +21,10 @@ func run(cmd *cobra.Command, args []string) { // kratos add helloworld/v1/helloworld.proto input := args[0] n := strings.LastIndex(input, "/") + if n == -1 { + fmt.Println("The proto path needs to be hierarchical.") + return + } path := input[:n] fileName := input[n+1:] pkgName := strings.ReplaceAll(path, "/", ".")