Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the variable name XXXX should conform to the errXxx format (errname) #442

Open
wwcchh0123 opened this issue Nov 11, 2024 · 0 comments
Open

Comments

@wwcchh0123
Copy link
Contributor

lint 解释

  • 在 Go 语言中,errXXX 是一种命名约定,规定错误变量的名称应符合特定的格式。具体来说,错误变量应该以 err 开头,并后接一个描述性的名称。这种命名约定有助于提高代码的可读性和一致性,使其他开发者能够快速识别错误变量。

错误用法

// 定义一个错误变量,不符合 errXXX  命名约定
var newkszbZeroBwError = errors.New("this is a zero bandwidth error")

正确用法

// 符合命名约定的错误变量
var errZeroBandwidth = errors.New("this is a zero bandwidth error")
var ErrZeroBandwidth = errors.New("this is a zero bandwidth error")
@wwcchh0123 wwcchh0123 changed the title the variable name newkszbZeroBwError should conform to the errXxx format (errname) the variable name XXXX should conform to the errXxx format (errname) Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant