```
package main
import (
_ "github.com/mattn/go-sqlite3"
"log"
"xorm.io/xorm"
)
type User struct {
ID int64
Name string
Age int
Author string
Published int
}
var x *xorm.Engine
func main() {
x, err := xorm.NewEngine("sqlite3", "test.db")
err = x.Sync2(new(User))
if err != nil {
log.Fatalf("Fail to sync database: %v\n", err)
}
}
```
运行后查看数据库表
![Screenshot_1.jpg](https://static.studygolang.com/210316/db84d7a50d6bb7802c4b2d01e7763e65.jpg)
更多评论