-
Notifications
You must be signed in to change notification settings - Fork 473
Open
Milestone
Description
I noticed the following code works fine:
c := *memcache.New()
err := c.Ping()
if err != nil {
panic(err)
}
fmt.Println("No problem")At first glance it looks okay - no hosts to ping means no errors, but there are a couple of problems:
- An actual client is constructed which is essentially non functional. Furthermore
New()doesn't return an error and the only way to verify if the client is in fact functional is to run another operation. - If we add further statements such as
err = c.Add(&memcache.Item{Key: "k", Value: []byte("v")})those will fail which leads to inconsistent behaviour in the API.
I suppose there are 2 ways to fix that - either change Ping() to check the hosts size, or change New() to do that and return an error
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels