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:
parent
8349b6c69f
commit
2ccf15a048
@ -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…
x
Reference in New Issue
Block a user