Ayiga / go-kit-middlewarer

A utility for generating layers for the go-kit framework
MIT License
85 stars 9 forks source link

Fix for go vet context leak warning added in go1.8 #11

Closed Morgahl closed 7 years ago

Morgahl commented 7 years ago

@Ayiga This set of changes is a small fix to add handling of context.CancelFunc returned from context.WithTimeout. This set of changes is due to new go vet directives added in go1.8 to handle context.CancelFunc instead of ignoring them. An example below:

go vet ../...
../transport/http/client_gen.go:28: the cancel function returned by context.WithTimeout should be called, not discarded, to avoid a context leak
exit status 1

Please review and let me know what you think on this.

Ayiga commented 7 years ago

Oooo... I would accept this. However, there's a very good chance that the name you gave for the cancel function could conflict with the name a user gives. c by itself is likely too common of a name. Therefore I'd recommend prefixing it with an underscore or something.

It doesn't follow normal naming conventions, but that's why I've ended up doing this so far, to avoid naming conflicts.

Morgahl commented 7 years ago

Good call. I've updated the template variables to be more expressive and follow your existing underscore-prefixed template variable convention.