-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (36 loc) · 881 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"fmt"
"github.com/yifanshaoye/ctdao/gorm"
"github.com/yifanshaoye/ctdao/zaplog"
)
type User struct {
ID int `gorm:"primary_key"`
Name string `gorm:"not_null"`
}
func main() {
fmt.Println("Hello, World !!!")
//rcli,_ := goredis.GetRedisInstance("", "", "")
//res := rcli.Get("a")
//fmt.Println( res)
//
//res = rcli.Get("b")
//fmt.Println( res)
//gorm.Done()
dsn := "root:long123456@tcp(127.0.0.1:3306)/collections?charset=utf8mb4&parseTime=True&loc=Local"
db, err := gorm.GetMysqlInstance(dsn)
fmt.Println("err: ", err)
user := []User{}
db.Find(&user)
fmt.Println(user)
userr := User{
Name: "log",
}
db.Create(&userr)
db.Find(&user)
fmt.Println(user)
//zaplog.SetLogFilePath("./database/access.log")
zaplog.InitZaplog()
zaplog.Info("test", "test log %+v", "zaplog")
zaplog.Error("second", "send log: %+v", "hahah error")
}