module
0.0.0-20230424084153-acdcd0d446aa
Repository: https://github.com/garyxiong123/go-learn.git
Documentation: pkg.go.dev
# README
go 基础和中间件
工作中用到的中间件 原理分析
0:语言基础
1:Log
日志
如何打印日志,为什么
2:错误/异常
- 错误规范
3: go zero
3.1 基础
3.2 gozero统一异常处理
- uniform error handler
3.3 限流
单机
集群
个人
接口
3.4 降级
3.5 熔断
3.6 go-contrl
3.7 命名规范
- 文件命名规范#
- 全部小写
- 除unit test外避免下划线(_)
- 文件名称不宜过长
- 命名准则#
- 当变量名称在定义和最后一次使用之间的距离很短时,简短的名称看起来会更好。
- 变量命名应尽量描述其内容,而不是类型
- 常量命名应尽量描述其值,而不是如何使用这个值
- 在遇到for,if等循环或分支时,推荐单个字母命名来标识参数和返回值
- method、interface、type、package推荐使用单词命名
- package名称也是命名的一部分,请尽量将其利用起来
- 使用一致的命名风格
- 变量命名规范参考#
- 首字母小写
- 驼峰命名
- 见名知义,避免拼音替代英文
- 不建议包含下划线(_)
- 不建议包含数字
- 函数、常量命名规范#
- 驼峰式命名
- 可exported的必须首字母大写
- 不可exported的必须首字母小写
- 避免全部大写与下划线(_)组合
-
编码规范
-
import#
- 子主题 1
-
函数返回#
- 对象避免非指针返回 ???
- 遵循有正常值返回则一定无error,有error则一定无正常值返回的原则
-
错误处理
- 有error必须处理,如果不能处理就必须抛出。
- 避免下划线(_)接收error
-
4:DB
4.1 事务
4.2 DB异常/异常细
4.3 dryRun
4.4 软删除
4.5 读写分离
4.3 拦截器
4.3 连接池
4.3 跟原生对比?
5:Cache
5.1 cache??【mark】
6:单元测试
7:swagger
8:eth
9: encrypt
10: go-cmd
11: ipfs
12: apollo
13: redis
14: circus
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author