package database import ( _ "github.com/mattn/go-sqlite3" "xorm.io/xorm" ) var engine *xorm.Engine type Wol struct { ID int Name string `xorm:"varchar(64)"` Mac string `xorm:"varchar(64)"` } func init() { var err error file := "./wol.db" engine, err = xorm.NewEngine("sqlite3", file) if err != nil { println(err) } } func CreateTable() int { err := engine.Sync2(new(Wol)) if err != nil { println(err) } return 0 } func Getallwol(everyone *[]Wol) { // everyone := make([]wol, 0) err := engine.Find(&(*everyone)) if err != nil { println("Getallwol err", err) } } func Getallwoltext() { everyone := make([]Wol, 0) err := engine.Find(&everyone) if err != nil { println("Getallwoltext", err) } println(len(everyone)) } func Insert(wol *Wol) { affected, err := engine.Insert(&wol) if err != nil { println(err) } println(affected) }