Skip to content

Ping reports successful on empty hosts #179

Description

@dimitrovvlado

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:

  1. 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.
  2. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions