这里我正在打印我的快照。我在下面发布了我希望快照打印出来的样子,并且还希望能够打印单个快照。我不知道如何做到这一点任何帮助都会很棒。
svc := ec2.New(&aws.Config{Region: "us-east-1"})
params := &ec2.DescribeSnapshotsInput{
OwnerIDs: []*string{
aws.String("130300684064"),
},
}
b, err2 := svc.DescribeSnapshots(params)
if err2 != nil {
panic(err2)
}
fmt.Printf(awsutil.StringValue(b))
以下是输出内容:http://imgur.com/3MnBNXI 这就是我想要输出的内容:
{
Snapshots:
----0
Description: "Snapshot from MULTI",
Encrypted: false,
OwnerID: "130300684064",
Progress: "100%!"(MISSING),
SnapshotID: "snap-81b1dff6",
StartTime: 2015-07-21 18:41:54 +0000 UTC,
State: "completed",
VolumeID: "vol-5121ebaa",
VolumeSize: 1
},{
----1
Description: "Snapshot from MULTI",
Encrypted: false,
OwnerID: "130300684064",
Progress: "100%!"(MISSING),
SnapshotID: "snap-08352a7f",
StartTime: 2015-07-21 18:41:54 +0000 UTC,
State: "completed",
VolumeID: "vol-9b21eb60",
VolumeSize: 1
},{
----2
Description: "Snapshot from MULTI",
Encrypted: false,
OwnerID: "130300684064",
Progress: "100%!"(MISSING),
SnapshotID: "snap-768ffb00",
StartTime: 2015-07-21 18:41:54 +0000 UTC,
State: "completed",
VolumeID: "vol-5620eaad",
VolumeSize: 1
}]
此处的完整代码:http://pastebin.com/QgmV6kRj
答案 0 :(得分:0)
如果要打印各个快照的详细信息,可以迭代响应:
resp, err := svc.DescribeSnapshots(params)
if err != nil {
log.Fatal(err)
}
for i, s := range resp.Snapshots {
fmt.Printf("Snapshot: %d\n", i)
fmt.Println(s)
}