Closed tyler-french closed 3 months ago
Maybe a follow-up, what about things like types
and enums:
func doSomething(input string) {
type x string
const (
y x = "0"
z x = "1"
)
...
https://github.com/uber-go/guide/blob/master/style.md#reduce-scope-of-variables kind of covers this, IMO. Perhaps adding some more examples with types/consts can be helpful?
Hoping to get some opinions on this.
One pattern I see a lot is with making global constants for values that are only used within a certain function.
For example
In my opinion, there should be an adjustment to the # Reduce Scope of Variables section to include more emphasis on what to do with Constants.
I mostly want to get opinions here, but I generally would prefer to change the above code to the following:
Thoughts?