Skip to content

Instantly share code, notes, and snippets.

@max107
Created April 22, 2014 23:14
Show Gist options
  • Save max107/11197623 to your computer and use it in GitHub Desktop.
Save max107/11197623 to your computer and use it in GitHub Desktop.
package main
import (
"github.com/coreos/go-etcd/etcd"
"log"
"strings"
)
var etcdKey string
var backends []string
func join(keys ...string) string {
return strings.Join(keys, "/")
}
func main() {
etcdKey = "/apps"
client := etcd.NewClient([]string{"http://127.0.0.1:4001"})
result, err := client.Get(join(etcdKey, "localhost:9000"), true, false)
if err != nil {
panic(err)
}
// url := "example.com1"
// if _, err := client.AddChild(join(etcdKey, "localhost:9000"), url, 0); err != nil {
// panic(err)
// }
for _, n := range result.Node.Nodes {
backends = append(backends, n.Value)
}
log.Printf("%v", backends)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment