Send and receive signals in parallel

Hi guys,

Could you help me pls, I’m trying to send signals in parallel:

var ws sync.WaitGroup
	for i := 0; i < chunks; i++ {
		go func(num int) {
                        // some action here
			time.Sleep(time.Duration(rand.Intn(10)) * time.Second)
			logger.Info("Extraction", "chunk", num)
			signal := MySignal{
				Message:  "Please merge chunk",
				ChunkNum: num,
			wf := activity.GetInfo(ctx).WorkflowExecution
			err := cli.SignalWorkflow(ctx, wf.ID, wf.RunID, "chunkExtracted", signal)
			if err != nil {
				logger.Error("Error sending the Signal", err)

but it looks like they still sent sequentially…probably I’m doing something wrong, I would appreciate for any help…

ok, I’ll reply to myself, in case someone is looking for the answer.
To receive signals in parallel you have to use Temporal goroutines, in my example it looks like this:

resChan := make(chan string, chunks)

	for i := 0; i < chunks; i++ {
		workflow.Go(ctx, func(gCtx workflow.Context) {
			signalChan := workflow.GetSignalChannel(gCtx, "chunkExtracted")
			selector := workflow.NewSelector(gCtx)
			selector.AddReceive(signalChan, func(channel workflow.ReceiveChannel, more bool) {
				var signal MySignal
				var result string
				err = workflow.ExecuteActivity(mergeCtx, "NextActivity", signal.ChunkNum).Get(gCtx, &result)
				if err != nil {
				resChan <- result

	workflow.Await(ctx, func() bool {
		return len(resChan) == chunks