gtag

package
v0.0.0-...-7e18bce Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

包gtag提供结构体标签内容存储的功能。

注意,此包中的函数不保证并发安全,这意味着你不能在运行时调用它们,而应该在启动过程中调用。 md5:d4777cc34c9b1efa

Index

Constants

View Source
const (
	Default           = "default"      // 结构体字段的默认值标签,用于从HTTP请求中接收参数。 md5:471b058e0363f634
	DefaultShort      = "d"            // Short name of Default.
	Param             = "param"        // 参数名称,用于将特定参数转换为指定的结构体字段。 md5:33028ec3fe66a79b
	ParamShort        = "p"            // Short name of Param.
	Valid             = "valid"        // 用于结构体字段的验证规则标签。 md5:c9767807e4fe1067
	ValidShort        = "v"            // Short name of Valid.
	NoValidation      = "nv"           // 对指定的结构体/字段不进行验证。 md5:93e44f590e6cd034
	ORM               = "orm"          // ORM标签用于ORM功能,根据不同的场景执行不同的功能。 md5:e901afff806207ee
	Arg               = "arg"          // Arg 标签用于结构体,通常用于命令行参数选项。 md5:819c478470e2eba6
	Brief             = "brief"        // 对结构体的简要标签,通常被视为摘要。 md5:8cc2e142b471c9b7
	Root              = "root"         // 结构体的根标签,通常用于嵌套命令的管理。 md5:626e49be7a599621
	Additional        = "additional"   // 结构体的附加标签,通常用于命令的额外描述。 md5:b76bf06e005ec042
	AdditionalShort   = "ad"           // Additional 的简短名称。 md5:2f155740ef9ae268
	Path              = `path`         // HTTP请求的路由路径。 md5:f9eb0f9346f6006b
	Method            = `method`       // 用于HTTP请求的路由方法。 md5:26ee97992f417756
	Domain            = `domain`       // 为HTTP请求路由域名。 md5:993e9bc0c52ceff9
	Mime              = `mime`         // HTTP请求/响应的MIME类型。 md5:03b1bf9c4c1ec6e7
	Consumes          = `consumes`     // HTTP请求的MIME类型。 md5:8cbc13892b01d8ed
	Summary           = `summary`      // 结构体的摘要,通常用于请求结构体中的OpenAPI。 md5:a1c99f363a83aea5
	SummaryShort      = `sm`           // Short name of Summary.
	SummaryShort2     = `sum`          // Short name of Summary.
	Description       = `description`  // 结构体的描述,通常用于请求结构体的OpenAPI中。 md5:90f620e59b2029fd
	DescriptionShort  = `dc`           // Description的简短名称。 md5:338cad0bd7b5b50b
	DescriptionShort2 = `des`          // Description的简短名称。 md5:338cad0bd7b5b50b
	Example           = `example`      // 用于结构体的示例,通常用于OpenAPI请求结构体中。 md5:d16a29f9cbc58ce1
	ExampleShort      = `eg`           // Short name of Example.
	Examples          = `examples`     // 用于结构体的示例,通常用于请求结构体中的OpenAPI。 md5:d49c8328492a0c33
	ExamplesShort     = `egs`          // 示例的简短名称。 md5:4eb934008e0e6ef7
	ExternalDocs      = `externalDocs` // 对结构体的外部文档说明,通常用于OpenAPI的请求结构体。 md5:92492f2c20afc6ea
	ExternalDocsShort = `ed`           // 外部文档的简短名称。 md5:5fb4e7b4dfa5434e
	GConv             = "gconv"        // GConv 定义了指定结构字段的转换目标名称。 md5:2be73c0f237cbc0f
	GConvShort        = "c"            // GConv 定义了指定结构字段的转换目标名称。 md5:2be73c0f237cbc0f
	Json              = "json"         // JSON标签受到stdlib的支持。 md5:2d11fa95e0d1d656
	Security          = "security"     //swagger.io/docs/specification/authentication/. md5:28d2c5914a05dfdb
	In                = "in"           //swagger.io/docs/specification/describing-parameters/. md5:13bb3747232af609
)

Variables

View Source
var StructTagPriority = []string{
	GConv, Param, GConvShort, ParamShort, Json,
}

StructTagPriority 定义了Map*/Struct*函数的默认优先级标签。 注意,`gconv/param` 标签由旧版本的包使用。强烈建议未来改用简短的标签 `c/p`。 md5:0d809ae278226ae3

Functions

func Get

func Get(name string) string

Get 获取并返回指定名称的存储标签内容。 md5:1a0a007cb18c41fa

func GetEnumsByType

func GetEnumsByType(typeName string) string

GetEnumsByType 根据类型名称检索并返回存储的枚举json。 类型名称格式如:github.com/gogf/gf/v2/encoding/gjson.ContentType md5:51961ee0c0c68589

func GetGlobalEnums

func GetGlobalEnums() (string, error)

GetGlobalEnums 获取并返回全局枚举。 md5:9652b5705ec1767f

func Parse

func Parse(content string) string

Parse 通过将所有标签名变量替换为其内容,解析并返回给定的`content`。 示例: gtag.Set("demo", "content") Parse(`This is {demo}`) -> `This is content`。 md5:b45c5273962c7662

func SetGlobalEnums

func SetGlobalEnums(enumsJson string) error

SetGlobalEnums 将全局枚举设置到包中。 注意,此操作不具备并发安全性。 md5:1967d957ac1f393c

func SetOver

func SetOver(name, value string)

SetOver 执行 Set 的功能,但如果 `name` 已经存在,它会覆盖旧的值。 md5:906ca9f516be44d0

func Sets

func Sets(m map[string]string)

通过map设置多个标签的内容。 md5:c02ae9dd9350cf50

func SetsOver

func SetsOver(m map[string]string)

SetsOver 的行为类似于 Sets,但如果 `name` 已经存在,它会覆盖旧值。 md5:6a87c6587ed9794f

func X设置值

func X设置值(name, value string)

X设置值 设置指定名称的标签内容。 请注意,如果`name`已经存在,该函数会引发恐慌。 md5:3b301b4174b60616

Types

This section is empty.

Jump to

Keyboard shortcuts

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