codeguard / s3gof3r

Fast, concurrent, streaming access to Amazon S3, including gof3r, a CLI. http://godoc.org/github.com/rlmcpherson/s3gof3r
MIT License
1 stars 0 forks source link

checkClose may not function as intended #4

Open taylorskalyo opened 8 years ago

taylorskalyo commented 8 years ago

This is the current code for the checkClose function:

func checkClose(c io.Closer, err error) {
    if c != nil {
        cerr := c.Close()
        if err == nil {
            err = cerr
        }
    }

}

It looks like the intended effect is to replace err with cerr if err is nil and cerr is not. However, this replacement is only valid inside the scope of this function. To persist the change, we probably want to make err an error pointer.

eldondevcg commented 8 years ago

Ha. 4ecf3c16aa1ebde1a25b2d4240595010598fd5d6 seems to change to what we have from exactly this. Still, I think this bit of code is an antipattern. Maybe we can inline in these places.