Created
June 9, 2020 10:55
-
-
Save naijab/fa2246b3006a9c739f48dca148366c19 to your computer and use it in GitHub Desktop.
Space X
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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