Closed jonathangjertsen closed 3 months ago
Hi @jonathangjertsen , thanks for reporting the issue.
Using in identifiers is not idiomatic in Go, that is why the rule complains on `record`
Sure, the proposed fix (record
) is not valid because it results to be a reserved word of the language. It could be possible to avoid these kinds of incorrect recommendations by checking against the list of reserved words.
In these cases, it could be tricky to propose an alternative name. Thus, the rule could just signal the naming problem without proposing a fix.
IMO, adding these checks isn't worth the performance and complexity penalities.
In your case, you could just use something like strukt
to avoid the names clash.
I will close the issue for now, and if it turns out to be impacting a larger number of users, I'll reopen it.
Describe the bug
I have a program in which there is a concept of "struct" which does not refer to go structs.
struct
is not a valid identifier, so I usestruct_
. This triggers thevar-naming
check, which saysdon't use underscores in Go names; var struct_ should be struct
.To Reproduce
Steps to reproduce the behavior:
go install github.com/mgechev/revive@latest
Expected behavior
If the result of removing the underscore is an invalid identifier,
var-naming
should eitherLogs
N/A
Desktop (please complete the following information):
Additional context
This issue seems related to #613, but regardless of whether one thinks underscores in this usecase, the check should not suggest an invalid name