如何使用go in lambda安全检查S3存储桶中是否存在文件?

I am working on a service for my project that is used to synchronize Lambdas works in AWS. The idea is to write a TrackerFile module that will store structures on S3. Each time I use the tracker, I will check if there is a file with the name assigned to the called tracker.

I have no idea but how to safely check if a file with a given name exists on S3. can you show a sample piece of code that would be able to return (bool, err) where bool is True if the file exists?

you can use the head_object api

The HEAD operation retrieves metadata from an object without returning the object itself. This operation is useful if you're only interested in an object's metadata. To use HEAD, you must have READ access to the object.

response = client.head_object(
Bucket='string',
IfMatch='string',
IfModifiedSince=datetime(2015, 1, 1),
IfNoneMatch='string',
IfUnmodifiedSince=datetime(2015, 1, 1),
Key='string',
Range='string',
VersionId='string',
SSECustomerAlgorithm='string',
SSECustomerKey='string',
RequestPayer='requester',
PartNumber=123
)