Proposal: Beautify code and project struct
liuhao2050 opened this issue · 2 comments
Is your feature request related to a problem? Please describe.
This project is write in go, but many code isn't following go styles. To be a great CNCF project, may be we should make our code more idiomatic. Following are some controversial codes:
- Package name not idiomatic
package bfe_server
In blog Package names of golang official
The style of names typical of another language might not be idiomatic in a Go program. Here are two examples of names that might be good style in other languages but do not fit well in Go:
- computeServiceClient
- priority_queue
- Imports block not sorted and grouped
import (
"net"
"sync"
)
import (
"github.com/bfenetworks/bfe/bfe_tls"
)
- Some function name spells incorrectly
func NewHttpsListener(listener net.Listener, config *bfe_tls.Config) *HttpsListener {
}
NewHttpsListener
should be named to NewHTTPSListener
4. Package docs not standard
// stat for request
package bfe_basic
Describe the solution you'd like
- Rename code and project struct use Uber-Go-Guide
- Import golang-ci-lint.
Additional context
Just some advice.
Good advice.
@liuhao2050 感谢您的反馈!
BFE项目已有近10年历史,项目早期代码规范与目前Go社区规范有少量差异(出于可读性考虑)。例如:
- 包名允许使用 _ 以提高可读性
- 导入的包按类别进行了分类及排序(标准库包、第三方包、自有包)
- 使用驼峰式命名风格(对于特殊名词术语也同样处理)
- 并未严格限制包级别注释的格式
其中1/2/3属于偏好性差异,对提高可读性无影响;第4有待优化,欢迎提交PR
在未统一调整前,最重要的是保持与项目一致的风格。