Skip to content

Instantly share code, notes, and snippets.

@naijab
Created June 9, 2020 10:55
Show Gist options
  • Save naijab/fa2246b3006a9c739f48dca148366c19 to your computer and use it in GitHub Desktop.
Save naijab/fa2246b3006a9c739f48dca148366c19 to your computer and use it in GitHub Desktop.
Space X
package main
import (
"fmt"
"spacex/client"
)
func main() {
countRocket1 := countRocket("falcon1")
fmt.Println("=======")
fmt.Println(countRocket1)
}
func countRocket(key string) int {
spacex := client.NewSpaceX("https://api.spacexdata.com/v3/")
result := spacex.GetAllLaunches()
countRocket := 0
for _, item := range result {
fmt.Println(item.Rocket.ID)
if item.Rocket.ID == key {
countRocket++
}
}
return countRocket
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment