为了账号安全,请及时绑定邮箱和手机立即绑定

关于golang中的结构体

关于golang中的结构体

PHP
元芳怎么了 2019-03-15 17:49:11
这些天看aws的golang sdk中结构体中有 _ struct{} `type:"structure"` 不知道 下划线 _ 是什么意思,注意不是tag // Please also see https://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/MultipartUpload type MultipartUpload struct { _ struct{} `type:"structure"` // Date and time at which the multipart upload was initiated. Initiated *time.Time `type:"timestamp" timestampFormat:"iso8601"` // Identifies who initiated the multipart upload. Initiator *Initiator `type:"structure"` // Key of the object for which the multipart upload was initiated. Key *string `min:"1" type:"string"` Owner *Owner `type:"structure"` // The class of storage used to store the object. StorageClass *string `type:"string" enum:"StorageClass"` // Upload ID that identifies the multipart upload. UploadId *string `type:"string"` }
查看完整描述

2 回答

?
SMILET

TA贡献1796条经验 获得超4个赞

这个叫struct tag

Go offers struct tags which are discoverable via reflection. These enjoy a wide range of use in the standard library in the JSON/XML and other encoding packages.

The community welcomed them and has built ORMs, further encodings, flag parsers and much more around them since, especially for these tasks, single-sourcing is beneficial for data structures.

查看完整回答
反对 回复 2019-03-18
  • 2 回答
  • 0 关注
  • 396 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信