摘要:
datamodels/user.go package datamodels type User struct { UserId int64 `json:"user_id" xorm:"not null pk autoincr BIGINT(20)"` Name string `json:"name"
阅读全文
posted @ 2020-09-21 00:11
longzhankunlun
阅读(665)
推荐(0)
摘要:
package main import ( "github.com/kataras/iris/v12" ) func main() { // 1.创建实例 app := iris.New() // 2.设置错误等级 //app.Logger().SetLevel("debug") // 3.注册模板
阅读全文
posted @ 2020-09-20 15:34
longzhankunlun
阅读(1089)
推荐(0)
摘要:
[]string 是字符串切片 ...string用作参数 ...参数语法形成了可变参数的参数。它将接受零个或多个string参数,并将它们作为切片引用 func f(args ...string) { fmt.Println(args) } func main() { args := []stri
阅读全文
posted @ 2020-09-15 14:02
longzhankunlun
阅读(5077)
推荐(0)
摘要:
Update的时候,如果用到MustCols,则MustCols里面的字段必须更新,如果初始化结构体没有给该字段赋值,那么将会把nil值强制更新上去 func (d *GiftDao) Delete(id int64) error { data := &models.User{Balance: 1,
阅读全文
posted @ 2020-09-15 13:22
longzhankunlun
阅读(310)
推荐(0)
摘要:
查看是否开启日志记录 SHOW VARIABLES LIKE "%general_log%; 如果没有开启,则开启日志记录,设置为OFF为关闭日志记录 SET GLOBAL general_log = 'ON'; 查看日志记录的路径 show variables like 'general_log_
阅读全文
posted @ 2020-09-15 00:19
longzhankunlun
阅读(347)
推荐(0)
摘要:
如果没有go-sql-driver/mysql就先安装 go get -u github.com/go-sql-driver/mysql 安装xorm,在cmd命令行下 go get github.com/go-xorm/xorm 再安装xorm的cmd命令工具 go get github.com/
阅读全文
posted @ 2020-09-13 23:48
longzhankunlun
阅读(627)
推荐(1)
摘要:
单任务队列耗时 package main import ( "crypto/rand" "fmt" "math/big" "strconv" "strings" "sync" "time" ) type task struct { id uint32 // callback chan int } v
阅读全文
posted @ 2020-09-12 17:28
longzhankunlun
阅读(1166)
推荐(0)
摘要:
package main import "sync" var sm sync.Map var sm1 *sync.Map var m map[int]string func main() { sm.Store(1, "xixi") sm1.Store(1, "xixi") // 此处因为没有分配内存
阅读全文
posted @ 2020-09-12 10:01
longzhankunlun
阅读(518)
推荐(0)
摘要:
import "math/rand" func luckyCode() int32 { seed := time.Now().UnixNano() // rand内部运算的随机数 code := rand.New(rand.NewSource(seed)).Int31n(int32(rateMax)
阅读全文
posted @ 2020-09-10 08:02
longzhankunlun
阅读(2014)
推荐(0)
摘要:
package main import ( "database/sql" "fmt" //"log" "strconv" "sync" _ "github.com/go-sql-driver/mysql" ) var ( dbConn *sql.DB err error ) type SimpleS
阅读全文
posted @ 2020-09-08 11:39
longzhankunlun
阅读(187)
推荐(0)