Some code improvements#868
Conversation
sosiska
commented
Apr 30, 2019
- Rewrite some if-else chains as a switch statements. Based on Go style guide: https://golang.org/doc/effective_go.html#switch
- Simplify some functions.
- Improvement of len() comparisons style, because builtin len() function can't return value smaller than zero.
- strings.ToLower comparison changed to strings.EqualFold.
- gofmt examples/addsvc/thrift/gen-go/addsvc/add_service-remote/add_service-remote.go file (was done automatically by my IDE ¯\(ツ)/¯ )
This is a style choice, one version isn't better or worse than the other, by default. Unless there is a clear win in legibility, changing these sorts of things is relatively unproductive code churn. I didn't see anything in the diff that would obviously warrant the changes, if you believe otherwise, please give justification.
These were done deliberately. Please revert. With those changes, happy to merge. |
Why check the obviously impossible option? if-else chains to switch cases rejected in 6f27a0c In examples/addsvc/thrift/gen-go/addsvc/add_service-remote/add_service-remote.go file main change on line number 78, |
|
len returns an int, ints can be negative, <= is safer. |
I do not agree, the source code is full of places where the result of the len() is compared with 0. |
|
If I wrote the code, I used |
https://github.com/go-kit/kit/blame/master/metrics/internal/lv/space.go#L82 ¯\(ツ)/¯ |
* Simplify some functions. * strings.ToLower comparison changed to strings.EqualFold.
Rejected in 40b2404 |
peterbourgon
left a comment
There was a problem hiding this comment.
Thanks! Sorry for the delay!
* Simplify some functions. * strings.ToLower comparison changed to strings.EqualFold.