09 2021 档案

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 阅读(768) 评论(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 阅读(301) 评论(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 阅读(405) 评论(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 阅读(934) 评论(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 阅读(96) 评论(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 阅读(111) 评论(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 阅读(131) 评论(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)

linux开放某个端口
摘要:1. 开放80端口[root@localhost ~]# firewall-cmd --add-port=80/tcp --permanentsuccess 2. reload防火墙[root@localhost ~]# firewall-cmd --reload 3.查看开放的所有端口 [root 阅读全文

posted @ 2021-09-07 17:50 torotoise512 阅读(139) 评论(0) 推荐(0)

Django使用HTTPS
摘要:Django使用HTTPS有两种方式: 一、使用Django-sslserver的方式 pip install django-sslserver # 安装django-sslserver INSTALLED_APPS = [ ... "sslserver", # 在settings里面添加sslse 阅读全文

posted @ 2021-09-07 15:24 torotoise512 阅读(1077) 评论(0) 推荐(0)

DRF认证、权限和限流
摘要:一、认证 这里只记录JWT的认证方式: 1. 首先针对用户需要创建JWT的token,方式如下: # jwt_auth.pyimport jwt,datetime from django.conf import settings def create_token(payload,timeout=30 阅读全文

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