samuel/go-zookeeper — pull request #14 by shurcooL (2013-09-04 00:39:27+00:00)
Title: Error on Lock() when part of path has already been created.

Currently, a lock can be created in the root node (e.g., `NewLock(zk, "/lock", acls)`).

However, when trying to create a lock inside another node (e.g., `NewLock(zk, "/something/lock", acls)`), it fails if one of the earlier nodes in the full path already exists (e.g., "/something" node exists, but "/something/lock" does not exist).

This patch fixes that.

The code in `NewLock()` has a `for _, p := range parts[1:] { ... }` loop that tries to create all the parent nodes along the path. If some of those nodes already exist, there will be an `ErrNodeExists` error, which should be ignored.