func (rc *ReceiveChannel) GetChannel() (chan []byte, error) {
	if rc.Ch != nil {
		return rc.Ch, nil
	}
	rc.Ch = make(chan []byte)
	go func() {
		target := rc.findTarget()
		rc.receiveTopicFrom(target)
	}()
	return rc.Ch, nil
}
Not thread safe
package receiver
import (
	"io"
	"log"
	"math/rand"
	"net"
	"time"
	"github.com/chrislusf/netchan/service_discovery/client"
	"github.com/chrislusf/netchan/util"
)
type ReceiveChannel struct {
	Ch     chan []byte
	offset uint64
	name   string
	Leader string
}
func (rc *ReceiveChannel) findTarget() (target string) {
	l := client.NewNameServiceAgent(rc.Leader)
	for {
		locations := l.Find(rc.name)
		if len(locations) > 0 {
			target = locations[rand.Intn(len(locations))]
		}
		if target != "" {
			break
		} else {
			time.Sleep(time.Second)
		}
	}
	return
}
func NewReceiveChannel(name string, leader string, offset uint64) *ReceiveChannel {
	return &ReceiveChannel{
		Leader: leader,
		name:   name,
		offset: offset,
	}
}