我想删除bucket/userID
.
但是下面有很多文件bucket/userID
我必须执行删除bucket/userID
,需要使用ListObjects
then DeleteObjects
。函数ListObjects
返回result.Contents
的是[]*s3.Object
But DeleteObjects
needs []*s3.ObjectIdentifier
。
我无法转换[]*s3.Object
为[]*s3.ObjectIdentifier
.
在这段代码中,发生了错误invalid memory address or nil pointer dereference
type Object struct {
_ struct{} `type:"structure"`
ETag *string `type:"string"`
Key *string `min:"1" type:"string"`
LastModified *time.Time `type:"timestamp"
timestampFormat:"iso8601"`
Owner *Owner `type:"structure"`
Size *int64 `type:"integer"`
StorageClass *string `type:"string" enum:"ObjectStorageClass"`
}
type ObjectIdentifier struct {
_ struct{} `type:"structure"`
Key *string `min:"1" type:"string" required:"true"`
VersionId *string `type:"string"`
}
objects := getObjects() // return []*s3.Object
a := make([]*s3.ObjectIdentifier, len(objects))
for i, v := range objects {
a[i].Key = v.Key
}
a[i].Key = v.Key
是错误。如何实现删除bucket/userID
?