Commit afe1a985 authored by Aksel Baardsen's avatar Aksel Baardsen
Browse files

changed from [] to map

parent 69cf765f
......@@ -5,14 +5,11 @@ import (
"github.com/gorilla/mux"
"log"
"net/http"
"os"
)
func main() {
r := mux.NewRouter()
port := os.Getenv("PORT")
port := "5000"//os.Getenv("PORT")
c := r.PathPrefix("/conservation/v1").Methods("GET").Subrouter()
// two handlerpaths makes sure that the caller does not HAVE to specify limit
......@@ -31,6 +28,5 @@ func main() {
http.Handle("/", r)
log.Fatal(http.ListenAndServe(":"+port, nil))
}
......@@ -54,8 +54,15 @@ func GetCountryByCode(code, limit string) (Country, int) {
}
// adds species-keys & specie-names to the country struct
check := make(map[Results]bool)
for i, _ := range species.Results {
// and checks if the country-code is correct
if check[species.Results[i]] {
continue
}
check[species.Results[i]] = true
country.SpeciesKey = append(country.SpeciesKey, species.Results[i].SpeciesKey)
country.Species = append(country.Species, species.Results[i].Species)
/* and checks if the country-code is correct
if country.Code == species.Results[i].CountryCode {
// and checks that the species is unique
if species.Results[i].SpeciesKey > 0 && !contains(country.SpeciesKey, species.Results[i].SpeciesKey) {
......@@ -63,6 +70,8 @@ func GetCountryByCode(code, limit string) (Country, int) {
country.SpeciesKey = append(country.SpeciesKey, species.Results[i].SpeciesKey)
}
}
*/
}
return country, status
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment