gtag

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: MIT Imports: 2 Imported by: 55

Documentation

Overview

Package gtag providing tag content storing for struct.

Note that calling functions of this package is not concurrently safe, which means you cannot call them in runtime but in boot procedure.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(name string) string

Get retrieves and returns the stored tag content for specified name.

func Parse

func Parse(content string) string

Parse parses and returns the content by replacing all tag name variable to its content for given `content`. Eg: If "Demo:content" in tag mapping, Parse(`This is {Demo}`) -> `This is content`.

func Set

func Set(name, value string)

Set sets tag content for specified name.

Example
package main

import (
	"fmt"

	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/util/gmeta"
	"github.com/gogf/gf/v2/util/gtag"
)

func main() {
	type User struct {
		g.Meta `name:"User Struct" description:"{UserDescription}"`
	}
	gtag.Sets(g.MapStrStr{
		`UserDescription`: `This is a demo struct named "User Struct"`,
	})
	fmt.Println(gmeta.Get(User{}, `description`))

}
Output:

This is a demo struct named "User Struct"

func Sets

func Sets(m map[string]string)

Sets sets multiple tag content by map.

Types

This section is empty.

Jump to

Keyboard shortcuts

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