Skip to content

Commit

Permalink
chore: replace strings.SplitN(arg, sep, 2) with strings.Cut(arg, sep) (
Browse files Browse the repository at this point in the history
  • Loading branch information
estensen authored Jan 8, 2024
1 parent b6ba613 commit f2bc119
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions jsonrpc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,11 @@ func (h *Handler) registerService(service Service) {
func (h *Handler) getFnHandler(req types.Request) (*serviceData, *funcData, types.Error) {
methodNotFoundErrorMessage := fmt.Sprintf("the method %s does not exist/is not available", req.Method)

callName := strings.SplitN(req.Method, "_", 2) //nolint:gomnd
if len(callName) != 2 { //nolint:gomnd
serviceName, funcName, found := strings.Cut(req.Method, "_")
if !found {
return nil, nil, types.NewRPCError(types.NotFoundErrorCode, methodNotFoundErrorMessage)
}

serviceName, funcName := callName[0], callName[1]

service, ok := h.serviceMap[serviceName]
if !ok {
log.Debugf("Method %s not found", req.Method)
Expand Down

0 comments on commit f2bc119

Please sign in to comment.