随笔分类 -  go

golang学习--字符串格式化
摘要:package main // 声明 main 包,表明当前是一个可执行程序 import "fmt" // 导入内置 fmt import "os" // 导入内置 fmt // 定义变量 var ( a int = 2 b string = "bb" ) // 定义常量 const ( c in 阅读全文

posted @ 2022-05-23 21:58 torotoise512 阅读(714) 评论(0) 推荐(0)

Golang密码复杂度校验
摘要://密码强度必须为字⺟⼤⼩写+数字+符号,8位以上 func CheckPasswordLever(ps string) error { if len(ps) < 8 { return fmt.Errorf("password len is < 9") } num := `[0-9]{1}` a_z 阅读全文

posted @ 2021-09-22 20:44 torotoise512 阅读(760) 评论(0) 推荐(0)

GORM的增删改查
摘要:一下列出了部分内容,详情可以查看官方文档,官方文档路径: https://gorm.io/zh_CN/docs/ https://www.kancloud.cn/sliver_horn/gorm/1861152 package main import ( "fmt" "strconv" "time" 阅读全文

posted @ 2021-09-21 16:20 torotoise512 阅读(295) 评论(0) 推荐(0)

GORM:创建数据
摘要:package main import ( "fmt" "strconv" "time" _ "github.com/go-sql-driver/mysql" "gorm.io/driver/mysql" "gorm.io/gorm" ) //定义一个结构体,gorm允许定义结构体的时候通过tag定 阅读全文

posted @ 2021-09-21 12:46 torotoise512 阅读(398) 评论(0) 推荐(0)

golang的time包:时间字符串和时间戳的相互转换
摘要:本博客转自:https://www.cnblogs.com/nyist-xsk/p/11448348.html package main import ( "log" "time" ) func main() { t := int64(1546926630) //外部传入的时间戳(秒为单位),必须为 阅读全文

posted @ 2021-09-21 10:53 torotoise512 阅读(932) 评论(0) 推荐(0)

GO操作数据库3【学习自李文周老师博客】
摘要:package main import ( "database/sql/driver" "fmt" _ "github.com/go-sql-driver/mysql" "github.com/jmoiron/sqlx" ) type student struct { Name string Age 阅读全文

posted @ 2021-09-20 20:07 torotoise512 阅读(89) 评论(0) 推荐(0)

GO操作数据库2【学习自李文周老师博客】
摘要:package main import ( "database/sql/driver" "fmt" "strings" "time" _ "github.com/go-sql-driver/mysql" "github.com/jmoiron/sqlx" ) type user struct { I 阅读全文

posted @ 2021-09-20 20:00 torotoise512 阅读(107) 评论(0) 推荐(0)

GO操作数据库1【学习自李文周老师博客】
摘要:package main import ( "fmt" "time" _ "github.com/go-sql-driver/mysql" "github.com/jmoiron/sqlx" ) type user struct { Id int Name string // 首字母大写,不然后面的 阅读全文

posted @ 2021-09-20 18:13 torotoise512 阅读(127) 评论(0) 推荐(0)

go调用mysql
摘要:package main import ( "database/sql" "fmt" _ "github.com/go-sql-driver/mysql" ) func main() { db, err := sql.Open("mysql", "root:123456@(127.0.0.1:330 阅读全文

posted @ 2021-09-20 16:08 torotoise512 阅读(31) 评论(0) 推荐(0)