package testUnit import ( "fmt" "goInOut/utils" "testing" ) // 定义一个结构体,包含嵌套的结构体字段 type Person struct { Name Name `json:"name"` } type Name struct { First string `json:"first"` Last string `json:"last"` } func Test_httpProxy(t *testing.T) { } func Test_template(t *testing.T) { // 创建一个Person实例 person := Person{ Name: Name{ First: "John", Last: "Doe", }, } templateStr := "Hello, {{.Name.First}} !" sbs, err := utils.TextTemplateMatch(person, templateStr) println(sbs) if err != nil { fmt.Println(err.Error()) } }