tag

package
v0.0.0-...-1781da9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2014 License: MIT Imports: 1 Imported by: 1

Documentation

Overview

tag包实现对特定格式的struct tag字符串的分析。 并不具有很强的通用性。支持以下两种格式的字符串。

1. 以分号分隔的字符串,每个子串又以逗号分隔, 第一个字符串为键名,之后的字符串组成的数组为键值。如:

"id,1;unique;fun,add,1,2;"
// 以下将会被解析成:
[
     "id"    :["1"],
     "unique":nil,
     "fun"   :["add","1","2"]
]

2.以分号分隔的字符串,每个子串括号前的字符串为健名, 括号中的字符串以逗号分隔组成数组为键值。如:

"id(1);unique;fun(add,1,2)"
// 以下将会被解析成:
[
     "id"    :["1"],
     "unique":nil,
     "fun"   :["add","1","2"]
]

Index

Constants

View Source
const Version = "0.2.1.141117"

当前库的版本

Variables

This section is empty.

Functions

func Get

func Get(tag, name string) ([]string, bool)

从tag中查找名称为name的内容。 第二个参数用于判断该项是否存在。

func Has

func Has(tag, name string) bool

查询指定名称的项是否存在,若只是查找是否存在该 项,使用Has()会比Get()要快上许多。

func MustGet

func MustGet(tag, name string, defVal ...string) []string

功能同Get()函数,但在无法找到的情况下,会返回defVal做为默认值。

func Parse

func Parse(tag string) map[string][]string

分析tag的内容,并以map的形式返回

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL