added fix for removing elements from the array

This commit is contained in:
2021-05-24 13:58:24 +04:00
parent 65e633e6c4
commit f89e7ccbcb
4 changed files with 12 additions and 17 deletions

View File

@@ -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:]...)
}