Go
JuiceFS 社区版、企业版、Dragonfly 集成性能测试及对比
· ☕ 6 分钟
1. 环境准备 进入一个安全目录 1 mkdir -p /data/test && cd /data/test 在这个目录下完成全部的测试任务。 给 Redis 单独建一个目录 1 mkdir redis-data 建议新建一个目录,因为 Redis 会将当前目录文件的 Owner 改成 systemd-coredump。如果是 HOME 目录下,可能会导致 SSH 验证失败,无法登录机器。 启动 Red

容器下的 Go 应用程序优化
· ☕ 2 分钟
1. 内存对齐 结构体内字段,从大到小排列 减少内存占用 安装 fieldalignment 工具 1 go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest 分析并修复内存对齐 1 2 3 4 5 6 7 8 9 fieldalignment -fix ./... /Users/shaowenchen/Code/app/config/config.go:136:14: struct with 32 pointer bytes could be 24 /Users/shaowenchen/Code/app/config/config.go:150:11: struct of size 96 could be 88 /Users/shaowenchen/Code/app/config/config.go:166:14: struct of size 152 could be 144 /Users/shaowenchen/Code/app/config/config.go:194:12: struct with 80 pointer bytes could be 72 /Users/shaowenchen/Code/app/config/config.go:209:12: struct with 56 pointer bytes could be 40 /Users/shaowenchen/Code/app/dao/gormx/gorm.go:12:13: struct with 16 pointer bytes could be 8 /Users/shaowenchen/Code/app/dao/gormx/entity/cluster.go:5:14: struct with 128 pointer bytes could be 104 查看 fieldalignment 进行

使用 Go 编写 WebAssembly 程序
· ☕ 4 分钟
1. WebAssembly 简介 跨平台性,可以在任何支持 WebAssembly 的平台上运行,包括 Web 浏览器、服务器、移动设备等 高性能,采用了一种紧凑的二进制格式,可以在浏览器中快速加载和解析,从而提高应用程序的性能 安全性,采用了一种沙箱模型,可以隔离运行在其中的代码,从而保护系统免受恶

Go mod 使用问题
· ☕ 1 分钟
1. 升级 Go 版本之后 go.sum 版本不匹配 执行命令 go build 报错。 错误提示: missing go.sum entry for module providing package golang.org/x/time/rate; to add 解决办法: 在 go build 之前更新 go.sum,执行命令 go mod tidy 2. tls 错误 执行命令 go mod download 报错。 错误提示: fatal: unable to access 'https://github.com/agiledragon/gomonkey/': GnuTLS recv error (-110): The TLS connection was non-properly terminated. 解决办法: 禁用证书校验执行命令,export

Go 中的时间和时区问题
· ☕ 4 分钟
1. 时间与时区 1.1 时间标准 UTC,世界标准时间,是现在的时间标准,以原子时计时。 GMT,格林威治时间,是以前的时间标准,规定太阳每天经过位于英国伦敦郊区的皇家格林威治天文台的时间为中午 12 点。 UTC 时间更加准确,但如果对精度要求不高,可以视两种标准等