Skip to content

Instantly share code, notes, and snippets.

@drKnoxy
Created December 30, 2016 19:47
Show Gist options
  • Save drKnoxy/0adee20217f71acb70958d30864fb1bd to your computer and use it in GitHub Desktop.
Save drKnoxy/0adee20217f71acb70958d30864fb1bd to your computer and use it in GitHub Desktop.
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