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

pull/831/head
Cluas 4 years ago committed by GitHub
parent 8349b6c69f
commit 2ccf15a048
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      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, "/", ".")

Loading…
Cancel
Save