跳过正文

Tech

服务器diskio过高问题排查
·209 字
iostat # iostat -x [间隔秒数] [监控多少秒]
本机PHP版本管理
·218 字
本地配置PHP版本管理 # 环境: wsl ubuntu22.04
Go类型之map
·255 字
负载因子6.5 # map引用传递 # map作为参数传递给函数时,是引用传递,引用传递类型还有slice和channel 函数对map的操作对原map变量是生效的
单元测试
·545 字
vscode配置go开发环境 # 设置goroot "go.goroot": "/usr/local/go-1.18.9",
Vim配置
·267 字
配置 # vim ~/.vimrc
Go语言编程中遇到的问题
·681 字
encoding/json # 序列化转义HTML字符 # json.Marshal()默认转义HTML字符("<", “>”, “&”, U+2028, and U+2029),源码如下
lsof
·222 字
lsof 输出各列信息 # column 描述 COMMAND 进程名称 PID 进程 ID USER 进程所属用户 FD 文件描述符 TYPE 文件类型,IPv4, REG 等 DEVICE 磁盘名称 SIZE/OFF 文件大小 NODE 索引节点,文件在磁盘上的标识 NAME 打开文件的名称 查看打开文件的进程 # lsof [filename]
浮点数
·318 字
IEEE-754 浮点数标准 # Go 使用 IEEE-754 标准,使用以 2 为底的指数表示小数,如 0.085 可以用指数的形式表示为 1.36*2^-4
Go常用第三方库
·200 字
功能 项目 备注 日志 https://github.com/uber-go/zap go get -u go.uber.org/zap 日志切割 https://github.com/natefinch/lumberjack go get -u github.com/natefinch/lumberjack.v2 orm https://github.com/go-gorm/gorm go get -u gorm.io/gorm redis https://github.com/go-redis/redis go get -u github.com/go-redis/redis/v9 json操作 https://github.com/tidwall/gjson go get -u github.com/tidwall/gjson json操作 https://github.com/tidwall/sjson go get -u github.com/tidwall/sjson json序列化 https://github.com/bytedance/sonic 配置管理 https://github.com/spf13/viper cli框架 https://github.com/spf13/cobra 类型转换 https://github.com/spf13/cast 熔断限流 https://github.com/alibaba/sentinel-golang 文档 redis分布式锁 https://github.com/go-redsync/redsync mock https://github.com/agiledragon/gomonkey 时间 https://github.com/golang-module/carbon 工具库 https://github.com/duke-git/lancet 各种工具方法集合 prometheus https://github.com/prometheus/client_golang go get -u github.com/prometheus/client_golang 链路追踪 go get -u go.opentelemetry.io/otel maxprocs https://github.com/uber-go/automaxprocs go get -u github.com/uber-go/automaxprocs, go1.25应该会解决容器环境cpu核数设置问题 限流 https://github.com/uber-go/ratelimit go get -u go.uber.org/ratelimit 测试框架 https://github.com/stretchr/testify go get -u github.com/stretchr/testify mock https://github.com/agiledragon/gomonkey swagger https://github.com/swaggo/swag uuid https://github.com/google/uuid go get -u github.com/google/uuid rpc https://github.com/grpc/grpc-go go get -u google.golang.org/grpc https://grpc.io/docs/languages/go/ 服务注册发现 https://github.com/etcd-io/etcd 参考
gorm使用问题集
·471 字
gorm连接被mysql server断开 # 报错如下 # [mysql] 2023/01/11 16:41:19 packets.go:122: closing bad idle connection: EOF 查看MySQL服务器连接超时时间, 28800s(8小时) # mysql> show global variables like 'wait_timeout'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | wait_timeout | 28800 | +---------------+-------+ 连接池设置 # 默认情况下,gorm客户端最大连接时间为0,即不主动断开连接