1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-03-17 21:07:54 +02:00

proto/add: avoid panic when using non-hierarchical path (#829)

This commit is contained in:
Cluas 2021-04-13 14:03:20 +08:00 committed by GitHub
parent 8349b6c69f
commit 2ccf15a048
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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, "/", ".")