doc.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2015 CoreOS, Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /*
  15. Package client provides bindings for the etcd APIs.
  16. Create a Config and exchange it for a Client:
  17. import (
  18. "net/http"
  19. "github.com/coreos/etcd/client"
  20. "golang.org/x/net/context"
  21. )
  22. cfg := client.Config{
  23. Endpoints: []string{"http://127.0.0.1:4001"},
  24. Transport: DefaultTransport,
  25. }
  26. c, err := client.New(cfg)
  27. if err != nil {
  28. // handle error
  29. }
  30. Create a KeysAPI using the Client, then use it to interact with etcd:
  31. kAPI := client.NewKeysAPI(c)
  32. // create a new key /foo with the value "bar"
  33. kAPI.Create(context.Background(), "/foo", "bar")
  34. // delete the newly created key only if the value is still "bar"
  35. kAPI.Delete(context.Background(), "/foo", &DeleteOptions{PrevValue: "bar"})
  36. */
  37. package client