You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-zero/example/etcd/pub/pub.go

28 lines
415 B
Go

4 years ago
package main
import (
"flag"
"fmt"
"log"
"time"
"github.com/tal-tech/go-zero/core/discov"
4 years ago
)
var value = flag.String("v", "value", "the value")
func main() {
flag.Parse()
client := discov.NewPublisher([]string{"etcd.discovery:2379"}, "028F2C35852D", *value)
if err := client.KeepAlive(); err != nil {
log.Fatal(err)
}
defer client.Stop()
for {
time.Sleep(time.Second)
fmt.Println(*value)
}
}