in

Yet another StructTag, with some features liked cache and alias


Yet another StructTag, with some features liked cache and alias.

package main
import (
	"fmt"
    
	"github.com/azhai/go-sftag"
)

// 连接配置
type ConnParams struct {
	Host     string                 `json:"host" yaml:"host" toml:"host"`
	Port     int                    `json:"port,omitempty" yaml:"port,omitempty" toml:"port"`
	Username string                 `yaml/json:"username,omitempty" toml:"username"`
	Password string                 `toml/yaml/json:"password"`
	Database string                 `toml/yaml/json:"database"`
	Options  map[string]interface{} `yaml/json:"options,omitempty" toml:"options"`
}

func main() {
	tags := sftag.GetStructTags(ConnParams{})
	tag := sftag.NewSfTag()
	tag.Parse(tags["Options"])
	fmt.Println(tag.Get("yaml"))
	fmt.Println(tag.String())
}

GitHub

View Github




Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

GIPHY App Key not set. Please check settings

How to Exclude Pages from WordPress Search Results (Step by Step)

chmod4 — Real time code sharing without the pain of screen sharing