coreos/go-etcd — pull request #32 by nemothekid (2013-09-09 16:14:08+00:00)
Title: Added ErrUserStopped variable to catch when the library is no longer watching a key

Currently I am using this pattern for key watching:

```go
go func(responseChannel chan *store.Response) {
for response := range updateNodes {
// do some work with new response
}
}(responseChannel)

go func(responseChannel chan *store.Response, stopChannel chan bool) {
for {
_, e := as.Etcd.Watch("mykey/x", 0, responseChannel, stopChannel)
if e.Error() == "User stoped watch" {
break
} else {
log.Print("Error watching: ", e)
}
}
close(responseChannel)
}(responseChannel, stopChannel)
/// do some work
stopChannel <- true
```

This way I can watch a key, and if the machine I'm listening on were to close for any other reason that I cancelled it,
it would attempt to watch the key again. What this pull request does is adds a `ErrUserStopped error` to the package so instead of

```if e.Error() == "User stoped watch" {```

I can write

```if e == etcd.ErrUserStopped {```

which I believe is more idiomatic. I kept the messages the same so that the previous code still works.