dubbo-go
dubbo-go copied to clipboard
If we need a code style?
What would you like to be added:
Good Code Style.
Why is this needed:
- Standardized code promotes teamwork
- Standardized code can reduce bug handling
- Standardized code can reduce maintenance costs
- Standardized code helps code review
How: Although golang does not have a recognized code specification, we can refer to those: https://go.dev/ref/spec https://github.com/golang/go/wiki/CodeReviewComments https://github.com/uber-go/guide/blob/master/style.md
e.g.
var localIp string
func GetLocalIp() string {
}
into
var localIP string
func GetLocalIP() string {
}
type Service struct {
name string
rcvr reflect.Value
rcvrType reflect.Type
methods map[string]*MethodType
}
into
type Service struct {
name string
rv reflect.Value // receiveValue
rt reflect.Type // receiveType
methods map[string]*MethodType
}
编码规范考虑划分如下大章节:
- 命名
- 本地变量命名
- 全局变量命名
- 全局常量命名
- 结构体命名
- 函数命名
- 注释
- 函数注释
- 结构体注释
- 控制结构
- 编码风格
- 代码对齐
- ...
+1
I think the code specification should be added into https://github.com/apache/dubbo-go/blob/master/CONTRIBUTING.md, and setup the linter on the github action to check if the code meet the specification.
I am writing the first edition of the code specification,and try to add it to this issue before this weekend.