Ben Johnson 1843f7bda5 bump(github.com/coreos/go-etcd): 0cc84e9bc81c45e074864360adc549e61a3a7f83 12 tahun lalu
..
etcd 1843f7bda5 bump(github.com/coreos/go-etcd): 0cc84e9bc81c45e074864360adc549e61a3a7f83 12 tahun lalu
examples 1843f7bda5 bump(github.com/coreos/go-etcd): 0cc84e9bc81c45e074864360adc549e61a3a7f83 12 tahun lalu
LICENSE 6813a92325 bump(github.com/coreos/go-etcd): 9d174bd052fc49e53d5978c2ecd81770aee3788d 12 tahun lalu
README.md d3fbf6d997 bump 3rd party 12 tahun lalu

README.md

go-etcd

golang client library for etcd

This etcd client library is under heavy development. Check back soon for more docs. In the meantime, check out etcd for details on the client protocol.

For usage see example below or look at godoc: go-etcd/etcd

Install

go get github.com/coreos/go-etcd/etcd

Examples

Returning error values are not showed for the sake of simplicity, but you should check them.

package main

import (
	"fmt"
	"github.com/coreos/go-etcd/etcd"
)

func main() {
	c := etcd.NewClient() // default binds to http://0.0.0.0:4001

	// SET the value "bar" to the key "foo" with zero TTL
	// returns a: *store.Response
	res, _ := c.Set("foo", "bar", 0)
	fmt.Printf("set response: %+v\n", res)

	// GET the value that is stored for the key "foo"
	// return a slice: []*store.Response
	values, _ := c.Get("foo")
	for i, res := range values { // .. and print them out
		fmt.Printf("[%d] get response: %+v\n", i, res)
	}

	// DELETE the key "foo"
	// returns a: *store.Response
	res, _ = c.Delete("foo")
	fmt.Printf("delete response: %+v\n", res)
}