package common_utils import ( "fmt" "log" "testing" "time" ) func TestIP4(t *testing.T) { ip4 := ReadIP4() println(ip4) } func TestIP4WithFilter(t *testing.T) { println("==================") prefix := "10." ip4 := ReadIP4WithPrefix(prefix) println(ip4) } func TestMqttReConn(t *testing.T) { client := NewMqttHelper( "10.8.30.160", 30883, fmt.Sprintf("%s-%s", "testReConn", time.Now().Format("20060102-150405")), "", "", false, ) client.Subscribe("re", onData) for { time.Sleep(time.Minute) } } func onData(topic, payload string) { log.Printf("[%s]收到数据 %s", topic, payload) }