Server function code:
func (s *service) CreateConsignment(ctx context.Context, req *pb.Consignment, resp *pb.Response) error {
consignment, err := s.repo.Create(req)
if err != nil {
return err
}
resp = &pb.Response{Created: true, Consignment: consignment}
return nil
}
Client code:
resp, err := client.CreateConsignment(context.Background(),consignment)
if err != nil {
log.Fatalf("create consignment error: %v", err)
}
But client's resp is:
{false <nil> [] {} [] 0}
the only way I can get it to work now is if to set resp in the server like this:
resp.Created = true
resp.Consignment = consignment
The issue here being:
resp = &pb.Response{Created: true, Consignment: consignment}
why is setting resp manually working but assigning it to the address of a new local variable doesn't?