摘要: 使用 Docker 部署一个简单的web项目 开发流程 在本地开发一个有静态文件服务的 web 服务程序 web 服务监听 ip + port 为 0.0.0.0:3000 在服务器上使用 Dockerfile 构建镜像 使用构建出的镜像运行容器 配置 Nginx 将端口代理到 web 服务的 30 阅读全文
posted @ 2024-04-20 21:45 等你下课啊 阅读(1220) 评论(0) 推荐(0)
摘要: Nginx的安装配置使用 安装 Nginx 在默认的 Ubuntu 源仓库中可用。想要安装它,运行下面的命令 sudo apt update sudo apt install nginx 一旦安装完成,Nginx 将会自动被启动。你可以运行下面的命令来验证它: sudo systemctl stat 阅读全文
posted @ 2024-04-12 00:06 等你下课啊 阅读(3102) 评论(0) 推荐(0)
摘要: package main import ( "fmt" "io" "strings" ) func main() { r := f1(-1) if r == nil { fmt.Println("r error") } else { r.Read([]byte("")) // panic: runt 阅读全文
posted @ 2024-03-27 18:20 等你下课啊 阅读(44) 评论(0) 推荐(0)
摘要: Go 切片 切片结构 源码包 src/runtime/slice.go 中 定义 slice 的结构为 type slice struct { array unsafe.Pointer len int cap int } array 指针指向底层数组 len 表示切片长度 cap 表示切片容量 切片 阅读全文
posted @ 2024-03-26 14:14 等你下课啊 阅读(96) 评论(0) 推荐(0)
摘要: Go 文件操作-读写文件 Go读取文件 整个文件读取进内存(适合读小文件) 1. 直接指定文件名读取 os.ReadFile() ioutil.ReadFile() (在 Go 1.16 开始,ioutil.ReadFile() 就等价于 os.ReadFile()) package main im 阅读全文
posted @ 2024-03-19 21:21 等你下课啊 阅读(300) 评论(0) 推荐(0)
摘要: GO 反转字符串 package main import "fmt" func main() { str := "hello,world" bytes := []byte(str) lenBytes := len(bytes) forLen := lenBytes / 2 for i := 0; i 阅读全文
posted @ 2024-03-19 18:12 等你下课啊 阅读(36) 评论(0) 推荐(0)
摘要: GO 下划线(_)的作用 import时使用下划线 import _ "net/http/pprof" 此时会调用对应包的init()函数进行初始化,不会使用包中的其他功能。 用下划线来接收返回值 _, err := http.Head(url) 判断结构体是否实现了接口 type Animal i 阅读全文
posted @ 2024-02-09 20:43 等你下课啊 阅读(40) 评论(0) 推荐(0)
摘要: Postgresql数据库 常用sql语句 1. 约束 1.1 主键约束 主键是用于在表中唯一标识行的列或列组。从技术上讲,主键约束是非空约束和UNIQUE约束的组合。 使用列级约束设置主键 使用列级约束设置主键, 只能设置一列作为主键,主键默认名称为tablename_pkey CREATE TA 阅读全文
posted @ 2023-02-06 09:40 等你下课啊 阅读(848) 评论(0) 推荐(0)
摘要: GO 使用嵌套map应该多次分配空间 demo package main import ( "fmt" ) func main() { // 初始化一个map var tmp map[int64]interface{} //tmp[1] = "abc" // panic:assignment to 阅读全文
posted @ 2022-12-27 15:43 等你下课啊 阅读(265) 评论(0) 推荐(0)
摘要: GO json.Unmarshal() 解析不区分json字段的大小写 demo package main import ( "encoding/json" "fmt" ) type Demo struct { ABD string `json:"ABD"` } type Demo2 struct 阅读全文
posted @ 2022-12-27 15:09 等你下课啊 阅读(789) 评论(0) 推荐(0)