yay/aur/utils.go

21 lines
389 B
Go
Raw Normal View History

2016-11-30 17:55:56 +00:00
package aur
import (
"encoding/json"
"net/http"
)
2016-12-17 00:40:51 +00:00
// BaseURL givers the AUR default address.
const BaseURL string = "https://aur.archlinux.org"
2016-11-30 17:55:56 +00:00
// getJSON handles JSON retrieval and decoding to struct
func getJSON(url string, target interface{}) error {
r, err := http.Get(url)
if err != nil {
return err
}
defer r.Body.Close()
return json.NewDecoder(r.Body).Decode(target)
}