gogs / git

Package GoGits - Git is a pure Go implementation of Git manipulation.
Apache License 2.0
176 stars 32 forks source link

Check error returns of Seek, fix global data race #6

Closed pwaller closed 9 years ago

pwaller commented 9 years ago

This code had a race in it, which actually Go itself once had in ioutil.Discard but subsequently got fixed:

https://github.com/golang/go/issues/4589

So readerSkip has been replaced with a copy to ioutil.Discard.

In addition, error checking for Seek has been added.

I've taken the liberty of removing some convenience definitions because some of them just aliased standard library functions making it harder to understand the code and spot that there were unchecked errors. This also shortens the code.

pwaller commented 9 years ago

Just to clarify, the code is only racy if the consumer of the library attempts to make concurrent reads to multiple objects.