1 Star 0 Fork 0

xfrm/structs

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
tags.go 695 Bytes
一键复制 编辑 原始数据 按行查看 历史
package structs
import "strings"
// TagOptions contains a slice of tag options
type TagOptions []string
// Has returns true if the given option is available in TagOptions
func (t TagOptions) Has(opt string) bool {
for _, tagOpt := range t {
if tagOpt == opt {
return true
}
}
return false
}
// ParseTag splits a struct field's tag into its name and a list of options
// which comes after a name. A tag is in the form of: "name,option1,option2".
// The name can be neglectected.
func ParseTag(tag string) (string, TagOptions) {
// tag is one of followings:
// ""
// "name"
// "name,opt"
// "name,opt,opt2"
// ",opt"
res := strings.Split(tag, ",")
return res[0], res[1:]
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/xfrm/structs.git
git@gitee.com:xfrm/structs.git
xfrm
structs
structs
v1.0.0

搜索帮助