import ( "github.com/coreos/go-etcd/etcd" ) func main() { client := etcd.NewClient([]string{"http://localhost:2379"}) response, err := client.Get("/foo", false, false) if err != nil { // handle error } fmt.Println(response.Node.Value) }
import ( "github.com/coreos/go-etcd/etcd" ) func main() { client := etcd.NewClient([]string{"http://localhost:2379"}) _, err := client.Set("/foo", "bar", 0) if err != nil { // handle error } }In this example, we create a new etcd client and use the Set() method to set the value of the /foo key to "bar". The third argument specifies the TTL (time-to-live) of the key-value pair in seconds. Package library: github.com/coreos/go-etcd/etcd.