package snmp import ( "sync" "testing" ) type Agent struct { ip string port int community string } func TestV2c(t *testing.T) { oids := map[string]string{ "1.3.6.1.2.1.1.5.0": "sysName", } agents := []Agent{ Agent{ ip: "192.168.1.229", port: 161, community: "test1252serc", }, Agent{ ip: "192.168.1.254", port: 161, community: "loafle", }, Agent{ ip: "192.168.1.99", port: 161, community: "public", }, Agent{ ip: "192.168.1.1", port: 161, community: "public", }, Agent{ ip: "192.168.1.2", port: 161, community: "public", }, } var wg sync.WaitGroup wg.Add(len(agents)) for _, agent := range agents { go func(a Agent) { res, _ := getV2(a.ip, a.port, a.community, oids) t.Log(res) defer wg.Done() }(agent) } wg.Wait() }