gpt4 book ai didi

go - Golang 结构中的过滤字段标签是什么?

转载 作者:IT王子 更新时间:2023-10-29 02:33:35 32 4
gpt4 key购买 nike

type User struct {
Id int
Password string `filtered:"true"`
}

引用 filtered: "true" 部分。从未在其他任何地方看到过,也无法在规范中找到任何相关信息。想必这类似于不导出字段?

有没有人有更多的信息?

最佳答案

语言没有为结构标签分配特殊含义,它们由寻找它们的包解释。

在这种情况下,filtered:true 对使用 User 类型的包来说意味着某种东西,并根据它认为合适的方式对其进行操作。这与 json: 标签在 encoding/json 中的工作方式相同。 .

关于go - Golang 结构中的过滤字段标签是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36019806/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com