首页 > 解决方案 > 什么是 locationName 标签以及如何使用它们?

问题描述

我正在查看适用于 aws ec2 的 go SDK。我不明白为什么 SDK 中几乎所有的结构都有这个标签:`locationName'

例如类型 DescribeInstancesOutput 结构 {

// The token to use 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"`

// Zero or more reservations.
Reservations []*Reservation `***locationName***:"reservationSet" locationNameList:"item" type:"list"`
// contains filtered or unexported fields

有谁知道标签的用途?

来源 - https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#DescribeInstancesOutput

标签: gotagsaws-sdk

解决方案


通过搜索源代码,它似乎与内部 json/xml 解析/编码一起使用。这类似于json标签的使用方式encoding/json

这个答案在 go 中的标签上非常深入。

它们可以与reflect包一起访问/使用。


推荐阅读