Why doesn't my activity return the struct?

hey folks, here’s my sample code. the activity, executeOperation is supposed to return a non-nil pointer to a struct and an error. however, when i run this line, futures[i].Get(ctx, &res), i noticed that the activity returns nil. i’m pretty sure executeOperation is returning non-nil, error though

i’m using go 1.23.7

type MyStruct struct {
	example string
}

func executeOperation(ctx context.Context, op *MyStruct) (*MyStruct, error) {
	op.example = "hi"
	return op, errors.New("test")
}

func MyWorkflow(ctx workflow.Context) ([]*MyStruct, error) {
	opts := workflow.ActivityOptions{
		StartToCloseTimeout: time.Second * 5,
		RetryPolicy: &temporal.RetryPolicy{
			InitialInterval:    1 * time.Second,
			MaximumAttempts:    2,
			BackoffCoefficient: 1.1,
		},
	}
	ctx = workflow.WithActivityOptions(ctx, opts)

	ops := []*MyStruct{{"test1"}, {"test2"}}
	futures := make([]workflow.Future, len(ops))
	for i, op := range ops {
		future := workflow.ExecuteActivity(ctx, executeOperation, op)
		futures[i] = future
	}

	results := make([]*MyStruct, len(ops))
	for i := 0; i < len(futures); i++ {
		var res *MyStruct
		if e := futures[i].Get(ctx, &res); e != nil {
			// do something
		}
		results[i] = res
	}

	return results, nil
}

Change your struct to use public fields:

type MyStruct struct {
	Example string
}

@maxim thanks for the response. updated my fields to public but still the same issue though

also i doubt the problem is due to the param in MyStruct since > in line - futures[i].Get(ctx, &res) , i noticed that the activity returns nil for res when there’s an error

why doesn’t execute activity return my response on error?

func executeOperation(ctx context.Context, op *MyStruct) (*MyStruct, error) {
	op.example = "hi"
	return op, errors.New("test") // op is clearly non-nil here
}

Temporal doesn’t support returning both the result and the error from activities and workflows. It is done to ensure compatibility with other languages.