我试图理解这个Go结构:type ListClustersOutput struct { _ struct{} `type:"structure"` // A list of all of the clusters for your account in the specified Region. Clusters []*string `locationName:"clusters" type:"list"` // The nextToken value to include in a future ListClusters request. When the // results of a ListClusters request exceed maxResults, you can use this value // to retrieve the next page of results. This value is null when there are no // more results to return. NextToken *string `locationName:"nextToken" type:"string"`}查看文档:https://golangdocs.com/structs-in-golang#defining-a-struct-in-go它给出了一个例子:type Fruit struct { name string}这似乎非常不同。在更复杂的代码中,我认为这等同于但努力解压缩它。Clusters []*string `locationName:"clusters" type:"list"`name string我正在努力找出很多东西 - 大多数例子似乎都是指切片。他们为什么使用?type: "list"list什么是 ?locationName如何访问该结构中列表的第一个元素?请注意,对于最后一个问题,如果我使用(where is of this struct类型),我会得到一个指针。例如:result.Clusters[0]result fmt.Println("Result: ", result.Clusters[0]) Result: 0xc000372260如何取消引用它?
2 回答
跃然一笑
TA贡献1826条经验 获得超6个赞
您正在与结构标记作斗争。在代码中:
Clusters []*string `locationName:"clusters" type:"list"`
“聚类”字段的类型为 (),声明的其余部分是 2 个结构标记,您应该使用结构标记获取标记的值。[]*string
- 2 回答
- 0 关注
- 123 浏览
添加回答
举报
0/150
提交
取消
