In AWS cli, you can delete all items under prefix:
aws s3 rm s3://mybucket/prefix/ --recursive
I would like to delete all items under prefix just by giving prefix name. Can this be done in go sdk? Closest answer I found was:
get keys from the `listobject`
deleteObjects(keys)
No. The CLI provides added conveniences around the SDK; the SDK just provides what the API exposes. When you do aws s3 rm s3://mybucket/prefix/ --recursive
in the CLI, the CLI's code does exactly what you described using the SDK: list all the objects with that prefix, then delete them. Don't expect all functionality in the CLI to be available in the SDK, just the functionality in the API.