lock: fix so it can succeed after failing

Currently there is a bug where if the lock fails once (for example
because the file is locked) then it will never succeed, because
the map entry is never set to false in this case.

Rather than fix in every place, we factor out the common code
from all the implementations and apply the fix there.

We also fix the issue that if the file is locked and the portable code
is being used, the error message says "file has non-zero size"
rather than "already locked".

The tests are changed to catch this case - they fail as expected when run
against the old code.

Change-Id: Ie10eff1ff6a430da6f7ee56c76b0c792da337fcb
7 files changed
tree: bb764a149a7f28d08a5770c7f968d3ba2b0dc739
  1. .gitignore
  2. .travis.yml
  5. README.md
  6. bytereplacer/
  7. cloud/
  8. ctxutil/
  9. errorutil/
  10. fault/
  11. jsonconfig/
  12. legal/
  13. lock/
  14. net/
  15. oauthutil/
  16. osutil/
  17. strutil/
  18. syncutil/
  19. wkfs/


travis badge

go4.org is a collection of packages for Go programmers.

They started out living in Camlistore‘s repo and elsewhere but they have nothing to do with Camlistore, so we’re moving them here.


  • single repo. go4 is a single repo. That means things can be changed and rearranged globally atomically with ease and confidence.

  • no backwards compatibility. go4 makes no backwards compatibility promises. If you want to use go4, vendor it. And next time you update your vendor tree, update to the latest API if things in go4 changed. The plan is to eventually provide tools to make this easier.

  • forward progress because we have no backwards compatibility, it‘s always okay to change things to make things better. That also means the bar for contributions is lower. We don’t have to get the API 100% correct in the first commit.

  • code review contributions must be code-reviewed. We‘re trying out Gerrithub, to see if we can find a mix of Github Pull Requests and Gerrit that works well for many people. We’ll see.

  • CLA compliant contributors must agree to the Google CLA (the same as Go itself). This ensures we can move things into Go as necessary in the future. It also makes lawyers at various companies happy. The CLA is not a copyright assignment; you retain the copyright on your work. The CLA just says that your work is open source and you have permission to open source it. See https://golang.org/doc/contribute.html#tmp_6

  • docs, tests, portability all code should be documented in the normal Go style, have tests, and be portable to different operating systems and architectures. We'll try to get builders in place to help run the tests on different OS/arches. For now we have Travis at least.


To add code to go4, send a pull request or push a change to Gerrithub.

To push to Gerrithub:

See https://review.gerrithub.io/Documentation/user-upload.html for more generic documentation.

(TODO: more docs on Gerrit, integrate git-codereview?)