Created
December 30, 2016 19:47
-
-
Save drKnoxy/0adee20217f71acb70958d30864fb1bd to your computer and use it in GitHub Desktop.
This file contains 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
func main() { | |
resp, err := search("hats") | |
if err != nil { | |
println("buggered") | |
} else { | |
fmt.Printf("%+v\n", resp) | |
} | |
} | |
func search(query string) (PhotoResponse, error) { | |
url := baseURL + "/search/photos/?query=" + query + "&client_id=" + applicationID | |
resp, err := http.Get(url) | |
if err != nil { | |
return PhotoResponse{}, err | |
} | |
defer resp.Body.Close() | |
var r PhotoResponse | |
if err := json.NewDecoder(resp.Body).Decode(&r); err != nil { | |
return PhotoResponse{}, err | |
} | |
return r, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment