97 Commits

Author SHA1 Message Date
xfy
214ea4e9a6 perf(cache,proxy): 使用 uint64 哈希键优化代理缓存性能
- ProxyCache 的 entries 和 pending map 从 string 改为 uint64 键
- 新增 buildCacheKeyHash 使用 FNV-64a 计算哈希(零分配)
- 增加原始键碰撞验证,防止哈希冲突误匹配
- 更新相关测试和基准测试

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 15:03:10 +08:00
xfy
49d33f8b0c feat(middleware/security): 新增 auth_request 外部认证中间件
- 支持将认证委托给外部服务,根据响应状态码决定请求是否继续
- 配置 URI、Method、Timeout 和自定义 Headers
- 支持 $request_uri 等变量在 Headers 中使用

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 14:37:29 +08:00
xfy
84d67c8570 feat(handler/static): 新增 alias 指令支持路径别名
- NewStaticHandlerWithAlias 创建带 alias 的静态文件处理器
- alias 与 root 互斥,支持路径替换而非附加
- 新增测试覆盖 alias 路径映射逻辑

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 14:37:20 +08:00
xfy
d48caf5183 feat(proxy): 新增代理响应临时文件处理,保护内存
- TempFileHandler 检测响应大小,超过阈值写入临时文件
- TempFileCleaner 定期清理过期临时文件
- 避免 SSR 攻击和内存溢出风险

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 14:37:13 +08:00
xfy
1a9059b1ff feat(stream): 新增 TCP/UDP Stream SSL/TLS 支持
- StreamSSLManager 管理服务端 TLS 终端和客户端 TLS 连接
- 支持证书加载、mTLS 客户端验证
- 并发安全的证书配置管理

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 14:37:02 +08:00
xfy
b7de258f4e feat(variable): 新增 SSL 客户端证书变量支持
- 新增 ssl_client_verify、ssl_client_serial、ssl_client_subject 等变量
- 支持从 TLS 连接状态提取客户端证书信息
- 用于日志记录和访问控制决策

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 14:36:53 +08:00
xfy
9d49349ee1 feat(ssl,config): 新增 Session Tickets 和 mTLS 客户端证书验证
- SessionTicketsConfig 支持 TLS 1.3 会话恢复,密钥轮换和持久化
- ClientVerifyConfig 支持双向 TLS 认证,CA 证书池和 CRL
- TLSManager 集成 SessionTicketManager 和 ClientVerifier
- 新增完整测试覆盖密钥轮换和客户端验证逻辑

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 14:36:47 +08:00
xfy
61455412eb feat(variable,proxy): 新增上游变量支持,集成到代理请求处理
- 新增 upstream_addr、upstream_status、upstream_response_time 等变量
- 新增 UpstreamTiming 结构体捕获连接、首字节、响应时间
- Proxy.ServeHTTP 集成变量上下文,记录上游时间
- 新增测试覆盖上游变量和计时功能

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 14:36:37 +08:00
xfy
b72394eb3b style(handler,server): 格式化测试代码结构体字段对齐
- 对齐 errorpage_test.go、static_test.go、pprof_test.go 中的结构体字段
- 纯代码格式化,无逻辑变更

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 13:30:00 +08:00
xfy
3711b12fad docs(server/pprof): 添加详细函数文档注释,修复注释错字
- 为 pprof.go 和 pprof_impl.go 的所有公开函数添加文档注释
- 包含参数说明、返回值描述、使用示例和注意事项
- 修复注释错字"厉止"→"停止"
- 补充包级文档说明核心功能和用途

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 13:30:00 +08:00
xfy
9495a548e6 feat(proxy,server,logging): 集成变量系统和 DNS 解析器
变量系统集成:
- logging: 访问日志使用 variable 包展开模板
- rewrite: 重写规则支持变量展开
- proxy: 请求/响应头设置支持变量展开

DNS 解析器集成:
- app: 创建并启用 Resolver
- server: SetResolver/GetResolver 方法传递给 proxy
- proxy: SetResolver/Start 方法,后台 DNS 刷新协程
- proxy_dns.go: DNS 刷新逻辑和 IP 直连支持

新增集成测试:
- internal/integration/variable_test.go
- internal/integration/resolver_test.go

文档更新:
- docs/config-reference.md 配置参考文档

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 11:36:49 +08:00
xfy
5a6f4d351f feat(resolver): 新增 DNS 解析器支持
新增 internal/resolver 包,提供动态 DNS 解析功能:
- Resolver 类型支持配置多个 DNS 服务器
- 内置缓存支持 TTL 和最大条目数限制
- 统计信息追踪查询次数和缓存命中率

配置层面:
- ResolverConfig 支持 addresses/valid/timeout/ipv4/ipv6/cache_size
- 添加配置验证逻辑

Target 增强:
- 新增 hostname/resolvedIPs 字段支持 IP 缓存
- NeedsResolve 方法判断是否需要重新解析
- NewTargetFromConfig 工厂函数

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 11:36:49 +08:00
xfy
c95f474539 feat(variable): 新增变量系统支持
新增 internal/variable 包,提供 Nginx 风格的变量展开功能:
- 支持 $remote_addr、$host、$uri、$args 等 30+ 内置变量
- 使用 sync.Pool 优化 VariableContext 分配
- 支持 set_response_info 存储响应状态信息

添加 github.com/google/uuid 依赖用于请求 ID 生成。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 11:36:49 +08:00
xfy
b6f8894d78 test(handler,middleware,server): 新增 try_files、错误页面、pprof 单元测试
- static_test.go: 新增 try_files 配置解析、占位符解析、SPA 场景测试
- errorpage_test.go: 新增错误页面管理器完整测试覆盖
- errorintercept_test.go: 新增错误拦截中间件功能测试
- pprof_test.go: 新增 pprof 性能分析端点测试

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 11:15:39 +08:00
xfy
4d108267c3 docs(nginx): 新增健康检查详解与7个高级模块文档
- 04-proxy-loadbalancing: 新增第18节主动健康检查详解
  - 被动检查vs主动检查对比、NGINX Plus health_check/match指令
  - Stream健康检查、gRPC健康检查、开源替代方案
- 新增 MQTT 模块文档 (33): broker负载均衡、Client ID路由
- 新增 OIDC 模块文档 (34): OpenID Connect认证、JWT验证
- 新增 Keyval 模块文档 (35): 动态键值存储、API管理接口
- 新增 流媒体模块文档 (36): HLS/FLV/MP4伪流媒体配置
- 新增 WebDAV 模块文档 (37): 文件共享服务器配置
- 新增 Zone Sync 模块文档 (38): 多节点状态同步
- 新增 HTTP Tunnel 模块文档 (39): HTTP CONNECT代理隧道
- 更新 README.md 目录索引

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 10:36:34 +08:00
xfy
238fa20e41 docs(config): 在默认配置生成中添加已实现功能的注释示例
新增 client_max_body_size、try_files、next_upstream、error_page 等功能的配置注释

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 10:35:45 +08:00
xfy
ae027b6218 docs: 移除过时的文档文件
清理 docs 目录下不再需要的文档内容。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 10:07:34 +08:00
xfy
d482e44bec refactor(server/pprof): 简化 switch 语句并移除未使用变量
- 将 switch 语句改为更简洁的 case 匹配形式
- 移除未使用的 cpuProfileWriter 变量
- 忽略 Flush/WriteTo 等无关的错误返回值

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 09:58:11 +08:00
xfy
3758f410ff style(benchmark): 修复文件末尾换行符
Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 09:58:11 +08:00
xfy
db73a362af docs(update-prompts): 更新提示词文档,移除过时的 plan.md 引用
Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 09:58:11 +08:00
xfy
ee4f7a5ca9 refactor(config): 移除已废弃的配置字段
移除以下已标记废弃的字段:
- AuthConfig.MinPasswordLength (auth)
- FileCacheConfig.LRUEviction (file_cache)
- TransportConfig.MaxIdleConns (transport)

同时清理相关的验证逻辑、默认值设置、测试代码和文档。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 09:50:32 +08:00
xfy
b30c84a38b feat(config): 标记废弃字段,新增负载均衡算法验证
- MinPasswordLength 和 MaxIdleConns 添加 Deprecated 注释
- 验证时对废弃字段输出警告提示
- 新增 stream 负载均衡算法有效性验证
- 添加负载均衡算法验证测试用例

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 09:33:55 +08:00
xfy
58e420b3ab docs(config): 新增完整配置字段参考文档
- 添加 docs/config-reference.md,列出所有配置字段及枚举值
- 更新 defaults.go 注释,补充 client_max_body_size、try_files、error_page 字段说明

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-07 22:22:21 +08:00
xfy
b294df740e docs: 更新 README 并添加 CHANGELOG v0.1.0
README 添加徽章、完善特性说明、配置示例、项目结构、开发指南
CHANGELOG 记录初始版本 0.1.0 的完整变更历史

Co-Authored-By: Claude <noreply@anthropic.com>
v0.1.0
2026-04-07 18:28:13 +08:00
xfy
766e9255fa feat(config,server,makefile): 新增 pprof 性能分析端点支持
- 新增 PprofConfig 配置结构,支持路径和 IP 访问控制
- 实现 PprofHandler 处理器,提供 CPU/heap/goroutine/block/mutex profile
- Makefile 新增 build-perf、build-pgo、pgo-collect 目标
- 支持 PGO (Profile-Guided Optimization) 构建

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-07 18:21:03 +08:00
xfy
2688ed6a9c docs: 更新 AGENTS.md 文档,新增 benchmark/netutil/scripts 目录
- 根目录新增 scripts/ 和 .github/ 目录说明
- internal 新增 benchmark/ 和 netutil/ 目录说明
- middleware 新增 bodylimit/ 和 errorintercept/ 目录说明
- 更新日期为 2026-04-07

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 17:51:31 +08:00
xfy
0c2ac445c2 refactor(benchmark,proxy): 改进错误处理,忽略未使用返回值
- benchmark tools 使用空白标识符忽略明确不关心的返回值
- proxy bench 测试统一错误处理风格
- 符合 Go 最佳实践,避免编译器警告

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 17:51:09 +08:00
xfy
cb45e824d4 feat(middleware,rewrite): 增强 FlagLast 语义与循环检测
- FlagLast 重新从第一条规则开始匹配(nginx 兼容行为)
- 新增全局迭代计数器检测循环,限制最多 10 次迭代
- FlagBreak 不触发循环检测,直接停止
- 新增测试覆盖跨规则循环、迭代限制、nginx 兼容语义

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 17:50:50 +08:00
xfy
23f5c08614 feat(handler,server): 静态文件新增 try_files 配置,集成新增中间件
- StaticHandler 支持 try_files 配置,用于 SPA 部署回退
- 支持 $uri 和 $uri/ 占位符解析
- Server 集成 bodylimit 中间件(全局和路径级别配置)
- Server 集成 errorintercept 中间件(错误页面拦截)
- Server 预加载错误页面到内存

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 17:50:38 +08:00
xfy
827d26c2b5 feat(handler,middleware,errorintercept): 新增自定义错误页面支持
- ErrorPageManager 预加载错误页面到内存,运行时无文件 I/O
- ErrorIntercept 中间件拦截 4xx/5xx 响应并应用自定义页面
- 支持特定状态码页面和默认页面配置
- 支持可选的响应状态码覆盖(如返回 200 OK)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 17:49:59 +08:00
xfy
deb9b3139a feat(middleware,bodylimit): 新增请求体大小限制中间件
- 支持 client_max_body_size 配置,单位支持 b/kb/mb/gb
- 支持全局配置和路径级别覆盖
- 超限返回 413 Request Entity Too Large
- 使用 io.LimitReader 强制限制实际读取字节数

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 17:49:47 +08:00
xfy
f6245c19e0 feat(proxy,loadbalance,config): 新增故障转移 (next_upstream) 支持
- 配置新增 NextUpstreamConfig 支持 tries 和 http_codes 参数
- 负载均衡器新增 SelectExcluding 方法用于故障转移排除选择
- 代理请求失败时自动尝试下一个健康后端
- 健康检查新增 MarkHealthy 方法用于故障转移成功后恢复状态

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 17:49:10 +08:00
xfy
d8ac807cb7 docs(nginx): 更新代理与 stream 文档,新增 njs/可观测性/ACME 指南
- 04: 新增 random 负载均衡、upstream 响应时间变量详解
- 10: 新增访问控制、连接限制、地理/真实IP模块、高级日志配置
- 24: 新增 worker_aio_requests、EPOLLEXCLUSIVE 详解
- 30: njs JavaScript 模块完整指南
- 31: OpenTelemetry 可观测性集成指南
- 32: ACME 自动证书管理指南

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-07 17:06:38 +08:00
xfy
0979b60ff2 test(cache,loadbalance,proxy,benchmark): 新增核心模块基准测试
- cache: LRU Get/Set 性能测试
- loadbalance: 负载均衡算法性能测试
- proxy: 代理处理性能测试
- benchmark/tools: 负载生成器和模拟后端工具

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-07 17:06:08 +08:00
xfy
355d7a18ae feat(makefile,scripts,ci): 新增基准测试基础设施与回归检测
- Makefile 添加 bench-stat/bench-compare/bench-save/bench-check 命令
- 新增 Python 回归检测脚本 check_regression.py
- 新增 GitHub Actions 基准测试工作流

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-07 17:05:42 +08:00
xfy
83e1fe38ba feat(config,handler,server): 支持多静态目录配置,新增路径前缀匹配
- Static 配置从单对象改为数组,支持多个静态目录
- StaticConfig 新增 Path 字段用于路径前缀匹配
- 添加 validateStatics 和 validatePathConflicts 验证函数
- 删除 config.example.yaml 示例文件(配置可通过 --generate 生成)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-07 16:26:55 +08:00
xfy
f2352ab9cc docs(config,stream,logging,handler,proxy,cache,server,ssl,middleware): 为核心模块添加详细 GoDoc 文档注释
- config: 为 Config 和所有子配置结构添加完整文档,包含使用示例和注意事项
- stream: 为负载均衡器和服务器添加详细的参数、返回值和功能说明
- logging: 为日志格式化和输出函数添加文档,说明支持的变量替换
- handler: 为路由器、静态文件和 sendfile 处理器添加文档
- proxy: 为健康检查器和代理功能添加完整文档
- cache/server/ssl/middleware: 补充相关模块的文档注释
- config.example.yaml: 添加可信代理配置、加密套件示例,更新压缩级别说明

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-07 15:36:09 +08:00
xfy
038c0639fd feat(middleware,http3,config): 增强 gzip_static 支持 Brotli,新增 HTTP/3 0-RTT 与性能配置验证
- gzip_static: 支持 .br 和 .gz 预压缩文件,按 br > gzip 优先级选择
- http3/server: 新增 Enable0RTT 配置,启用时输出安全警告
- config: 废弃 FileCache.LRUEviction 字段,新增 validatePerformance 验证
- 新增 gzip_static 完整测试套件覆盖编码优先级、路径遍历防护等场景

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-07 14:25:28 +08:00
xfy
20016ebb59 feat(config): 增强配置验证功能,添加多项验证函数
新增 validateLogging、validateRewrite、validateSecurityHeaders 验证函数,
完善限流算法、滑动窗口模式、一致性哈希键格式验证,
在 YAML 默认配置中添加 trusted_proxies 字段说明。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-07 13:15:27 +08:00
xfy
3cc2dc7625 style(netutil,server,test): 修复代码格式问题,更新文档
- 修复 server.go 缩进问题
- 添加文件末尾换行符
- 格式化测试文件表格对齐
- 更新 update-prompts.md 添加新任务

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 11:38:54 +08:00
xfy
ff260def3b test(loadbalance,security): 完善模块测试覆盖率
loadbalance 模块覆盖率从 52.4% 提升至 96.1%:
- TestConsistentHash: 一致性哈希算法测试
- TestIsValidAlgorithm: 算法验证函数测试

security 模块覆盖率从 50.2% 提升至 63.7%:
- TestNewSlidingWindowLimiter: 滑动窗口限流器创建测试
- TestSlidingWindowLimiter_Allow: 请求允许/拒绝测试
- TestSlidingWindowLimiter_Reset/ResetAll: 重置测试
- TestSlidingWindowLimiter_Cleanup: 清理测试
- TestSlidingWindowLimiter_GetStats/GetCount: 统计测试

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-03 18:38:35 +08:00
xfy
0a50678b55 test(handler): 完善 handler 模块测试覆盖率
覆盖率从 45.3% 提升至 58.5%,新增测试:
- TestStaticHandler_SetFileCache: 文件缓存设置测试
- TestStaticHandler_SetGzipStatic: Gzip 静态文件设置测试
- TestStaticHandler_Handle_HeadRequest: HEAD 请求测试
- TestStaticHandler_Handle_WithCache: 带缓存处理测试
- TestStaticHandler_Handle_Precompressed: 预压缩文件测试
- TestStaticHandler_Handle_LargeFile: 大文件处理测试
- TestStaticHandler_Handle_Symlink: 符号链接测试

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-03 18:35:39 +08:00
xfy
77fdb11b06 test(server): 完善 server 模块测试覆盖率
覆盖率从 44.2% 提升至 45.8%,新增测试:
- TestPoolWrapHandler: 协程池处理器包装测试
- TestPoolWrapHandler_WhenStopped: 池停止时包装测试
- TestServer_Proxies: 代理管理测试
- TestServer_Running: 运行状态测试
- TestServer_StopWithNilFastServer: 无服务器停止测试
- TestServer_GracefulStopWithNilFastServer: 无服务器优雅停止测试
- TestServer_GetProxyCacheStats: 代理缓存统计测试
- TestServer_BuildMiddlewareChain_EmptyConfig: 空配置中间件链测试
- TestServer_TrackStats_EmptyBody: 空响应体统计测试

注:Start/startSingleMode 等启动函数适合集成测试

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-03 18:33:10 +08:00
xfy
f698f0af67 test(app): 完善 app 模块测试覆盖率
覆盖率从 44.3% 提升至 51.7%,新增测试:
- TestSetupSignalHandlers: 信号处理设置测试
- TestHandleSignal_SIGUSR2: SIGUSR2 热升级信号测试
- TestGracefulUpgrade_NoListener: 无监听器热升级测试
- TestVersionVariables: 版本变量默认值测试
- TestAppFields: App 结构体字段初始化测试
- TestShutdownHTTP3_WithServer: HTTP3 关闭测试
- TestReopenLogs_WithNilConfig: nil 配置重开日志测试
- TestReloadConfig_WithValidConfig: 多次重载配置测试
- TestHandleSignal_AllSignals: 所有信号类型综合测试

注:Run 方法涉及服务器启动循环,适合集成测试而非单元测试

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-03 18:30:41 +08:00
xfy
79037a873a test(logging): 完善 logging 模块测试覆盖率
覆盖率从 32.6% 提升至 96.5%,新增测试:
- TestLoggerWarn: Warn 级别日志测试
- TestInit: Init 函数初始化测试
- TestGlobalLogFunctions: 全局日志函数测试
- TestLogAccessGlobal: 全局 LogAccess 测试
- TestFormatAccessLog: 模板格式访问日志测试
- TestFormatAccessLogWithUser: 带 remote_user 的格式测试
- TestNewAppLogger: AppLogger 创建测试
- TestAppLoggerLogStartup/Shutdown/Signal: 应用生命周期日志测试
- TestAppLoggerMethods: AppLogger Info/Error 方法测试
- TestLoggerClose: Close 方法测试

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-03 18:28:09 +08:00
xfy
7a98a0b044 refactor: 抽取网络工具函数到 netutil 包,移除冗余代码
- 新增 internal/netutil 包,统一 IP 提取和 URL 解析函数
- proxy/websocket/middleware 使用 netutil 替代重复实现
- 移除 handler/sendfile 中未使用的 BufferPool 相关代码
- 移除 http3/adapter 中未使用的反向转换函数
- 提取 server.registerStaticHandler 函数改进代码结构
- 优化 access.go 锁范围,减少持锁时间

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-03 18:24:21 +08:00
xfy
cd2d1a8194 refactor: 优化字符串构建方式,统一测试错误处理风格
- 使用 fmt.Fprintf 替代冗余的 WriteString(fmt.Sprintf) 组合
- 测试中 nil 检查使用 t.Fatal 替代 t.Error 立即终止
- .gitignore 添加 html/ 目录忽略

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-03 17:49:11 +08:00
xfy
a1d84c1144 docs: 更新开发提示文档,添加代码质量检查任务
- 更新已有提示使用"深度分析"措辞
- 添加重复代码检测任务
- 添加 lint 检查任务

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-03 17:37:13 +08:00
xfy
fc71cf4835 refactor(test): 统一测试文件错误处理风格
使用空白标识符忽略测试辅助函数中 Close、ReadFrom、Set 等返回值,
与主代码风格保持一致。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-03 17:37:05 +08:00
xfy
96ed39e162 refactor(http3,handler,server,middleware): 改进错误处理与代码优化
- 使用 _ 忽略 Close、Write、Shutdown 等返回值
- compression 使用 switch-case 替代 if-else 链
- http3/adapter 使用 for-range 替代 VisitAll 遍历头部
- sendfile 添加 nolint 注释说明 buffer pool 设计决策
- defer 关闭文件使用 func() { _ = file.Close() } 确保执行

Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-03 17:36:58 +08:00