import ( "context" "fmt" "github.com/coreos/etcd/client" ) func main() { cfg := client.Config{ Endpoints: []string{"http://localhost:2379"}, } etcd, err := client.New(cfg) if err != nil { panic(err) } kapi := client.NewKeysAPI(etcd) resp, err := kapi.Get(context.Background(), "/foo/bar", nil) if err != nil { panic(err) } fmt.Println(resp.Node.Value) }
import ( "context" "fmt" "github.com/coreos/etcd/client" ) func main() { cfg := client.Config{ Endpoints: []string{"http://localhost:2379"}, } etcd, err := client.New(cfg) if err != nil { panic(err) } kapi := client.NewKeysAPI(etcd) for { resp, err := kapi.Get(context.Background(), "/baz/qux", &client.GetOptions{Wait: true}) if err != nil { panic(err) } fmt.Println(resp.Node.Value) } }Package library: github.com/coreos/etcd/client