-
Notifications
You must be signed in to change notification settings - Fork 492
Question: don't use leading k in Go names. Why? #258
Comments
Idiomatic Go doesn't use Hungarian notation and variable names shouldn't be prefixed with their intended use. For example, a constant should be named |
Thank you for the answer. I have a |
@DavidGamba Are you using a recent version of golint? Looking at the code, it only matches on lowercase |
@dominikh, I apologize, the actual name I have is |
Hi, I am bit by this rule. I have a kafka consumer and a partition consumer in my struct. I am naming them as What is the recommendation here ? Do I have to name it |
I am also having issues with this where I am parsing an array of strings of the form
I am clearly NOT using Hungarian notation here - the This is clearly a bug in golint in this case, or at best an annoying false positive. Is there any way we can fix this? Thanks! |
I'm writing a web server for a site which serves information about a phonetic orthography I've made for English for fun. In one template processing file I have these vars:
(Most of the phonemes in the above code were omitted here to conserve space.) I am told, 'don't use leading k in Go names; var kIPA should be iPA'. If you look at the pattern here, I am clearly not using Hungarian notation. I think this shouldn't be marked as a problem. |
How about using for k, v := range params {
kTrim := strings.TrimSpace(k)
vTrim := strings.TrimSpace(v)
delete(params, k)
params[kTrim] = vTrim
} |
Just adding one more corner case in which this rule bit us, we wrote a function that implements a k shortest path routing algorithm and obviously we called it Unfortunately that's also mistakenly identified as Hungarian notation. |
I can't find any reference indicating why Golint warns when doing this. Some explanation would be greatly appreciated!
The text was updated successfully, but these errors were encountered: