blizzy78 / varnamelen

Go analyzer checking that the length of a variable's name matches its usage scope
MIT License
20 stars 2 forks source link

ok pattern #1

Closed 1995parham closed 2 years ago

1995parham commented 2 years ago

There are cases like:

id, ok := claims["user_id"].(int)
if !ok {
}

which ok is a known pattern.

blizzy78 commented 2 years ago

Good point. I've just added the -ignoreTypeAssertOk flag that will allow to ignore ok variables that hold the bool return value of a type assertion.

I will also add similar flags for the bool return values of channel receive and map index.

The ok variable name will be hard-coded for the time being.

1995parham commented 2 years ago

Thank you for your attention and work :+1: