相关疑难解决方法(0)

Go中的标签有什么用途?

Go语言规范中,它提到了标签的简要概述:

字段声明后面可以跟一个可选的字符串文字标记,该标记成为相应字段声明中所有字段的属性.标签通过反射界面可见,但否则将被忽略.

// A struct corresponding to the TimeStamp protocol buffer.
// The tag strings define the protocol buffer field numbers.
struct {
  microsec  uint64 "field 1"
  serverIP6 uint64 "field 2"
  process   string "field 3"
}
Run Code Online (Sandbox Code Playgroud)

这是一个非常简短的解释IMO,我想知道是否有人可以提供我这些标签的用途?

reflection struct go

364
推荐指数
3
解决办法
8万
查看次数

标签 统计

go ×1

reflection ×1

struct ×1