123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package gonsq
- import (
- "encoding/json"
- "log"
- "testing"
- "time"
- )
- func Test_nsq(t *testing.T) {
- p, e2 := NewProducer("192.168.3.207:4150", "tt", false)
- go func() {
- log.Println(p, e2)
- time.Sleep(3 * time.Second)
- p.Publish([]byte("aaaa1111"))
- }()
- c, e1 := NewConsumer(&Cconfig{
- IsJsonEncode: false,
- Addr: "192.168.3.207:4150",
- Topic: "tt",
- Channel: "cc",
- Concurrent: 1,
- })
- log.Println(c, e1)
- go func() {
- for {
- select {
- case obj := <-c.Ch:
- log.Println("ccc", obj)
- }
- }
- }()
- select {}
- }
- func Test_arr(t *testing.T) {
- v, _ := json.Marshal([]byte("aaaa1111"))
- var n []byte
- json.Unmarshal(v, &n)
- log.Println(v, n, []byte{0xFF})
- }
|