fork of https://github.com/sourcegraph/zoekt
1package grpcutil
2
3import "strings"
4
5// SplitMethodName splits a full gRPC method name (e.g. "/package.service/method") in to its individual components (service, method)
6//
7// Copied from github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/reporter.go
8func SplitMethodName(fullMethod string) (string, string) {
9 fullMethod = strings.TrimPrefix(fullMethod, "/") // remove leading slash
10 if i := strings.Index(fullMethod, "/"); i >= 0 {
11 return fullMethod[:i], fullMethod[i+1:]
12 }
13 return "unknown", "unknown"
14}