From b55ad07ea255252037708474e7817f787d15d0d4 Mon Sep 17 00:00:00 2001 From: a <a@tuxpa.in> Date: Fri, 17 Feb 2023 01:08:10 -0600 Subject: [PATCH] edit helpers --- helper.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/helper.go b/helper.go index 04fa2b7..56bdb8b 100644 --- a/helper.go +++ b/helper.go @@ -2,11 +2,20 @@ package jrpc import "context" -func Do[T any](ctx context.Context, c Conn, method string, args any) (T, error) { +func Do[T any](ctx context.Context, c Conn, method string, args any) (*T, error) { var t T - err := c.Do(ctx, t, method, args) + err := c.Do(ctx, &t, method, args) if err != nil { - return t, err + return nil, err } - return t, nil + return &t, nil +} + +func Call[T any](ctx context.Context, c Conn, method string, args ...any) (*T, error) { + var t T + err := c.Call(ctx, &t, method, args) + if err != nil { + return nil, err + } + return &t, nil } -- GitLab