From 0cc4c91e01ed9175b568c5255423d2983fe29bc1 Mon Sep 17 00:00:00 2001 From: Denis Zheleztsov Date: Sun, 9 Jul 2017 16:53:49 +0300 Subject: [PATCH] Sort childrens in ls: /v1/ls/path/to/node --- rest/zoo.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rest/zoo.go b/rest/zoo.go index 32cadcb..f89491b 100644 --- a/rest/zoo.go +++ b/rest/zoo.go @@ -3,6 +3,7 @@ package rest import ( "github.com/samuel/go-zookeeper/zk" "log" + "sort" "strings" "time" ) @@ -26,7 +27,7 @@ type Zk struct { func (conf Zk) InitConnection() (*zk.Conn, error) { conn, _, err := zk.Connect(conf.Hosts, time.Second) if err != nil { - log.Panic("[ERROR] ", err) + log.Fatal("[ERROR] ", err) } return conn, err @@ -77,6 +78,9 @@ func (z ZooNode) GetChildrens(path string) Ls { // } // } + // Sort childrens alphabeticaly + sort.Strings(childrens) + l.Error = "" l.Childrens = childrens l.ZkStat = zkStat