Example #1
0
func Demo(m interface{}) {
	f := "Name"
	v, _ := mtag.GetTag(m, f, "label")
	xorm, _ := mtag.GetTag(m, f, "xorm")
	fmt.Printf("%s\n", v)
	fmt.Printf("%s\n", xorm)

	fmt.Println("zh:", mtag.GetLabelZH(m, f))

	fmt.Println("en:", mtag.GetLocaleLabel(m, f, "en"))
	fmt.Println("en_US:", mtag.GetLocaleLabel(m, f, "en_US"))
	fmt.Println("zh_CN:", mtag.GetLocaleLabel(m, f, "zh_CN"))

	fmt.Println("de:", mtag.GetLocaleLabel(m, f, "de"))
	fmt.Println("End of Demo\n\n")
}
Example #2
0
func TestParse(t *testing.T) {
	v, _ := mtag.GetTag(Model{}, "Name", "tag")
	if v != "hello" {
		t.Error("tag value not equals as expect.")
	}
}