utils.go 389 B

1234567891011121314151617181920
  1. package aur
  2. import (
  3. "encoding/json"
  4. "net/http"
  5. )
  6. // BaseURL givers the AUR default address.
  7. const BaseURL string = "https://aur.archlinux.org"
  8. // getJSON handles JSON retrieval and decoding to struct
  9. func getJSON(url string, target interface{}) error {
  10. r, err := http.Get(url)
  11. if err != nil {
  12. return err
  13. }
  14. defer r.Body.Close()
  15. return json.NewDecoder(r.Body).Decode(target)
  16. }