diff --git a/golang/go_template.go b/golang/go_template.go index 4816401..b608b1f 100644 --- a/golang/go_template.go +++ b/golang/go_template.go @@ -195,9 +195,9 @@ func (rc *rpcClient) Exec(ctx context.Context, rpcReq zenrpc.Request) (*zenrpc.R return nil, fmt.Errorf("bad response (%d)", resp.StatusCode) } - var zresp *zenrpc.Response + var zresp zenrpc.Response if rpcReq.ID == nil { - return zresp, nil + return &zresp, nil } bb, err := io.ReadAll(resp.Body) @@ -205,10 +205,10 @@ func (rc *rpcClient) Exec(ctx context.Context, rpcReq zenrpc.Request) (*zenrpc.R return nil, fmt.Errorf("response body (%s) read failed: %w", bb, err) } - if err = json.Unmarshal(bb, zresp); err != nil { + if err = json.Unmarshal(bb, &zresp); err != nil { return nil, fmt.Errorf("json decode failed (%s): %w", bb, err) } - return zresp, nil + return &zresp, nil } ` diff --git a/golang/testdata/catalogue_client.go b/golang/testdata/catalogue_client.go index 6d38547..11d809b 100755 --- a/golang/testdata/catalogue_client.go +++ b/golang/testdata/catalogue_client.go @@ -558,9 +558,9 @@ func (rc *rpcClient) Exec(ctx context.Context, rpcReq zenrpc.Request) (*zenrpc.R return nil, fmt.Errorf("bad response (%d)", resp.StatusCode) } - var zresp *zenrpc.Response + var zresp zenrpc.Response if rpcReq.ID == nil { - return zresp, nil + return &zresp, nil } bb, err := io.ReadAll(resp.Body) @@ -568,9 +568,9 @@ func (rc *rpcClient) Exec(ctx context.Context, rpcReq zenrpc.Request) (*zenrpc.R return nil, fmt.Errorf("response body (%s) read failed: %w", bb, err) } - if err = json.Unmarshal(bb, zresp); err != nil { + if err = json.Unmarshal(bb, &zresp); err != nil { return nil, fmt.Errorf("json decode failed (%s): %w", bb, err) } - return zresp, nil + return &zresp, nil }