package Nats import ( "Cold_DeductionNotice/conf" "Cold_DeductionNotice/lib" "Cold_DeductionNotice/logs" "github.com/nats-io/nats.go" "time" ) func NatsInit() { time.Sleep(time.Second * 3) var err error // 连接Nats服务器 lib.Nats, err = nats.Connect("nats://" + conf.NatsServer_Url) if err != nil { logs.Println("nats 连接失败!") panic(any(err)) } logs.Println("nats OK!") }