摘要: Go 文件操作-读写文件 Go读取文件 整个文件读取进内存(适合读小文件) 1. 直接指定文件名读取 os.ReadFile() ioutil.ReadFile() (在 Go 1.16 开始,ioutil.ReadFile() 就等价于 os.ReadFile()) package main im 阅读全文
posted @ 2024-03-19 21:21 等你下课啊 阅读(237) 评论(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 等你下课啊 阅读(26) 评论(0) 推荐(0)
摘要: GO 下划线(_)的作用 import时使用下划线 import _ "net/http/pprof" 此时会调用对应包的init()函数进行初始化,不会使用包中的其他功能。 用下划线来接收返回值 _, err := http.Head(url) 判断结构体是否实现了接口 type Animal i 阅读全文
posted @ 2024-02-09 20:43 等你下课啊 阅读(24) 评论(0) 推荐(0)
摘要: Postgresql数据库 常用sql语句 1. 约束 1.1 主键约束 主键是用于在表中唯一标识行的列或列组。从技术上讲,主键约束是非空约束和UNIQUE约束的组合。 使用列级约束设置主键 使用列级约束设置主键, 只能设置一列作为主键,主键默认名称为tablename_pkey CREATE TA 阅读全文
posted @ 2023-02-06 09:40 等你下课啊 阅读(776) 评论(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 等你下课啊 阅读(237) 评论(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 等你下课啊 阅读(734) 评论(0) 推荐(0)
摘要: Uber Go 语言编码规范 Uber Go 语言编码规范 阅读全文
posted @ 2022-12-27 14:13 等你下课啊 阅读(25) 评论(0) 推荐(0)
摘要: windows kill port netstat -ano | findstr 5678 // 查找端口为 5678 的进程,同时显示pid taskkill /f /pid 19696 // /F: 指定强制终止进程。 阅读全文
posted @ 2022-10-28 18:01 等你下课啊 阅读(31) 评论(0) 推荐(0)
摘要: GO 常用工具函数 // 求两个时间戳(单位 秒)之间间隔的自然天数 // // 2022-07-04 00:00 2022-07-05 xx:xx => 1 // 2022-07-04 00:00 2022-07-04 xx:xx => 0 func DiffIntervalNatureDays( 阅读全文
posted @ 2022-07-01 11:30 等你下课啊 阅读(161) 评论(0) 推荐(0)
摘要: Shell 打包发布脚本 常用打包发布脚本 打包脚本 (在Windows环境中编译成二进制文件后, 拷贝至服务器) #!/bin/bash BIN=erp-api make build #api Server echo "please input password:xxxxx" scp -P 22 阅读全文
posted @ 2022-05-31 18:11 等你下课啊 阅读(186) 评论(0) 推荐(0)