How to make the worker to log the failed task just once

I used go-sdk, set one workflow with following options:

func HandleName(ctx workflow.Context, name string) (string, error) {
	retryPolicy := &temporal.RetryPolicy{
		InitialInterval:    time.Second,
		BackoffCoefficient: 2.0,
		MaximumInterval:    time.Minute,
		MaximumAttempts:    2,
	}
	options := workflow.ActivityOptions{
		StartToCloseTimeout: time.Minute,
		RetryPolicy:         retryPolicy,
		HeartbeatTimeout:    10 * time.Second,
	}

	ctx = workflow.WithActivityOptions(ctx, options)
	f := workflow.ExecuteActivity(ctx, activity.SayHello, name)
	res := new(string)
	err := f.Get(ctx, res)
	if err != nil {
		fmt.Printf("failed to say hello to %s, because %s\n", name, err)
		return "", err
	}
	return *res, nil
}

the activity function is defined as below:

func SayHello(ctx context.Context, name string) (string, error) {
	sdkActivity.RecordHeartbeat(ctx, "hello world", name)
	msg := fmt.Sprintf("Hello, %s!", name)
	time.Sleep(30 * time.Second)
	return msg, nil
}

then the task failed after running, i suppose the function: RecordHeartbeat should be called in a goroutine periodically, maybe like this?

	go func() {
		for {
			sdkActivity.RecordHeartbeat(ctx, "hello world", name)
			time.Sleep(1 * time.Second)
		}
	}()

then could anyone tell me which signal is applied to quit the goroutine,
in addtion, i found the worker continue to log the error periodically which seems redundant:

2024-08-15 12:24:07.737397|INFO|-|4520:0:373|-|handle_name.go:53|-:workflow.(*TemporalUlogger).Info|-|Task processing failed with error|-:-|{"Namespace":"default","TaskQueue":"test_task_queue_name","WorkerID":"ooooo","WorkerType":"ActivityWorker","Error":{"Message":"invalid activityID or activity already timed out or invoking workflow is completed","CurrentCluster":"","ActiveCluster":""}}
2024-08-15 12:25:18.745201|INFO|-|4520:0:388|-|handle_name.go:53|-:workflow.(*TemporalUlogger).Info|-|Task processing failed with error|-:-|{"Namespace":"default","TaskQueue":"test_task_queue_name","WorkerID":"ooooo","WorkerType":"ActivityWorker","Error":{"Message":"invalid activityID or activity already timed out or invoking workflow is completed","CurrentCluster":"","ActiveCluster":""}}
2024-08-15 12:26:28.754958|INFO|-|4520:0:368|-|handle_name.go:53|-:workflow.(*TemporalUlogger).Info|-|Task processing failed with error|-:-|{"Namespace":"default","TaskQueue":"test_task_queue_name","WorkerID":"ooooo","WorkerType":"ActivityWorker","Error":{"Message":"invalid activityID or activity already timed out or invoking workflow is completed","CurrentCluster":"","ActiveCluster":""}}
2024-08-15 12:27:39.760908|INFO|-|4520:0:411|-|handle_name.go:53|-:workflow.(*TemporalUlogger).Info|-|Task processing failed with error|-:-|{"Namespace":"default","TaskQueue":"test_task_queue_name","WorkerID":"ooooo","WorkerType":"ActivityWorker","Error":{"Message":"invalid activityID or activity already timed out or invoking workflow is completed","CurrentCluster":"","ActiveCluster":""}}
2024-08-15 12:28:50.767121|INFO|-|4520:0:400|-|handle_name.go:53|-:workflow.(*TemporalUlogger).Info|-|Task processing failed with error|-:-|{"Namespace":"default","TaskQueue":"test_task_queue_name","WorkerID":"ooooo","WorkerType":"ActivityWorker","Error":{"Message":"invalid activityID or activity already timed out or invoking workflow is completed","CurrentCluster":"","ActiveCluster":""}}

how to make the worker log the failed task just once instead of periodically logging