Compare commits

..

No commits in common. "master" and "v0.2-Linux-d0a8fdfb11d6372eece119f8f2a67e2184de97cd" have entirely different histories.

1 changed files with 18 additions and 22 deletions

View File

@ -3,7 +3,6 @@ package main
import (
"encoding/json"
"fmt"
"io"
"log"
"math/rand"
"net"
@ -23,7 +22,7 @@ type stationRecord struct {
}
func RandomIP(iplist []net.IP) net.IP {
rand.NewSource(time.Now().Unix())
rand.Seed(time.Now().Unix())
randomIndex := rand.Intn(len(iplist))
return iplist[randomIndex]
}
@ -51,12 +50,7 @@ func GetStations(qstring string) ([]stationRecord, error) {
if err != nil {
log.Print(err.Error())
}
defer func(Body io.ReadCloser) {
err := Body.Close()
if err != nil {
log.Print(err.Error())
}
}(resp.Body)
defer resp.Body.Close()
var data []stationRecord
err = json.NewDecoder(resp.Body).Decode(&data)
@ -101,3 +95,5 @@ func StationSearch(name string, country string, state string, tags string, notok
prunedStations := pruneStations(stations) // eliminate stations that are reporting down.
return prunedStations, err
}