abbot / go-http-auth

Basic and Digest HTTP Authentication for golang http
Apache License 2.0
544 stars 121 forks source link

a bit of optimization #41

Closed razonyang closed 7 years ago

abbot commented 7 years ago

I'm not sure what exactly is optimised this way? FWIW I'd prefer to keep context value check explicit. Also, naked returns are generally discouraged. See https://github.com/golang/go/wiki/CodeReviewComments#named-result-parameters

razonyang commented 7 years ago

@abbot just for explaining my thought, and thanks your reply. :)

info, ok := ctx.Value(infoKey).(*Info)
// If false was returned, info is nil, in my humble opinion,
 // it is not necessary to check the result of assertion.
if !ok {
        return nil
}
return info