added fix for removing elements from the array
This commit is contained in:
@@ -1,16 +1,3 @@
|
||||
{
|
||||
"ip_address": [
|
||||
{
|
||||
"ipv4": "147.75.100.225",
|
||||
"latency": 1582411,
|
||||
"download": 279180.07603469375,
|
||||
"upload": 855366.1394760027
|
||||
},
|
||||
{
|
||||
"ipv4": "86.99.70.106",
|
||||
"latency": 134446840,
|
||||
"download": 1582.176490711659,
|
||||
"upload": 597823.3252726822
|
||||
}
|
||||
]
|
||||
"ip_address": null
|
||||
}
|
||||
@@ -8,9 +8,9 @@ func (ip *IpAddresses)SpeedTest() error{
|
||||
for i, value := range ip.IpAddress {
|
||||
|
||||
var err error
|
||||
if len(ip.IpAddress) == 1 {
|
||||
i = 0
|
||||
}
|
||||
//if len(ip.IpAddress) == 1 {
|
||||
// i = 0
|
||||
//}
|
||||
|
||||
// Ping Test
|
||||
err = value.PingTest()
|
||||
@@ -40,6 +40,12 @@ func (ip *IpAddresses)SpeedTest() error{
|
||||
}
|
||||
// Remove element from struct
|
||||
for _, index := range RemoveIndex {
|
||||
// If there is only 1 element and that has to be
|
||||
// removed
|
||||
if len(ip.IpAddress) == 1 {
|
||||
ip.IpAddress = nil
|
||||
break
|
||||
}
|
||||
ip.IpAddress = append(ip.IpAddress[:index], ip.IpAddress[index+1:]...)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user