我正在向AWS进行API调用,以使用Golang SDK获取AMI的列表。 DescribeImages
函数需要DescribeImagesInput
。我只想看到我自己的AMI,所以我的代码是这样做的:更好的初始化
// Build input
self := "self"
ownerSelf := []*string{&self}
ownImages := &ec2.DescribeImagesInput{
Owners: ownerSelf,
}
// Call the DescribeImages Operation
resp, err := svc.DescribeImages(ownImages)
if err != nil {
panic(err)
}
像这样的建筑输入是非常丑陋的。我相信有一种更好的技术,但作为Golang n00b,我不知道。什么是更好的方法?