// 定义结构体
type Person struct {
FirstName string `db:"first_name"`
LastName string `db:"last_name"`
Email string `db:"email"`
}
// 创建对象
personStructs := Person{FirstName: "Ardie", LastName: "Savea", Email: "[email protected]"}
// 插入到数据库
// sqlx 将 sql 语言中的“:field”替换为对象字段的值
_, err = db.NamedExec(`INSERT INTO person (first_name, last_name, email)
VALUES (:first_name, :last_name, :email)`, personStructs)