fix(mod): update vendored modules

This commit is contained in:
Jguer 2020-02-27 19:26:35 +01:00
parent 2ffde239c0
commit f4503ade39
No known key found for this signature in database
GPG key ID: 6D6CC9BEA8556B35
4 changed files with 25 additions and 11 deletions

2
go.mod
View file

@ -4,7 +4,7 @@ require (
github.com/Jguer/go-alpm v0.0.0-20191122171459-5cffc6e8fc69
github.com/Morganamilo/go-pacmanconf v0.0.0-20180910220353-9c5265e1b14f
github.com/Morganamilo/go-srcinfo v1.0.0
github.com/mikkeloscar/aur v0.0.0-20191216074712-ebecb34b95b4
github.com/mikkeloscar/aur v0.0.0-20200113170522-1cb4e2949656
)
go 1.13

4
go.sum
View file

@ -4,5 +4,5 @@ github.com/Morganamilo/go-pacmanconf v0.0.0-20180910220353-9c5265e1b14f h1:ptFKy
github.com/Morganamilo/go-pacmanconf v0.0.0-20180910220353-9c5265e1b14f/go.mod h1:Hk55m330jNiwxRodIlMCvw5iEyoRUCIY64W1p9D+tHc=
github.com/Morganamilo/go-srcinfo v1.0.0 h1:Wh4nEF+HJWo+29hnxM18Q2hi+DUf0GejS13+Wg+dzmI=
github.com/Morganamilo/go-srcinfo v1.0.0/go.mod h1:MP6VGY1NNpVUmYIEgoM9acix95KQqIRyqQ0hCLsyYUY=
github.com/mikkeloscar/aur v0.0.0-20191216074712-ebecb34b95b4 h1:qPyKOVOjHT0dJOS3FFYQzXTOa9gyDOL7CnjCWltkYtM=
github.com/mikkeloscar/aur v0.0.0-20191216074712-ebecb34b95b4/go.mod h1:nYOKcK8tIj69ZZ8uDOWoiT+L25NvlOQaraDqTec/idA=
github.com/mikkeloscar/aur v0.0.0-20200113170522-1cb4e2949656 h1:j679+jxcDkCFblYk+I+G71HQTFxM3PacYbVCiYmhRhU=
github.com/mikkeloscar/aur v0.0.0-20200113170522-1cb4e2949656/go.mod h1:nYOKcK8tIj69ZZ8uDOWoiT+L25NvlOQaraDqTec/idA=

View file

@ -10,6 +10,11 @@ import (
//AURURL is the base string from which the query is built
var AURURL = "https://aur.archlinux.org/rpc.php?"
var (
// ErrServiceUnavailable represents a error when AUR is unavailable
ErrServiceUnavailable = errors.New("AUR is unavailable at this moment")
)
type response struct {
Error string `json:"error"`
Version int `json:"version"`
@ -22,7 +27,7 @@ type response struct {
type By int
const (
Name By = iota
Name By = iota + 1
NameDesc
Maintainer
Depends
@ -86,13 +91,12 @@ func get(values url.Values) ([]Pkg, error) {
if err != nil {
return nil, err
}
if resp.StatusCode == http.StatusServiceUnavailable {
return nil, errors.New("AUR is unavailable at this moment")
}
defer resp.Body.Close()
if err := getErrorByStatusCode(resp.StatusCode); err != nil {
return nil, err
}
dec := json.NewDecoder(resp.Body)
result := new(response)
err = dec.Decode(result)
@ -119,6 +123,16 @@ func searchBy(query, by string) ([]Pkg, error) {
return get(v)
}
func getErrorByStatusCode(code int) error {
switch code {
case http.StatusBadGateway, http.StatusGatewayTimeout:
return ErrServiceUnavailable
case http.StatusServiceUnavailable:
return ErrServiceUnavailable
}
return nil
}
// Search searches for packages using the RPC's default search by.
// This is the same as using SearchBy With NameDesc
func Search(query string) ([]Pkg, error) {

4
vendor/modules.txt vendored
View file

@ -1,9 +1,9 @@
# github.com/Jguer/go-alpm v0.0.0-20191021114528-e11e8a60f385
# github.com/Jguer/go-alpm v0.0.0-20191122171459-5cffc6e8fc69
github.com/Jguer/go-alpm
# github.com/Morganamilo/go-pacmanconf v0.0.0-20180910220353-9c5265e1b14f
github.com/Morganamilo/go-pacmanconf
github.com/Morganamilo/go-pacmanconf/ini
# github.com/Morganamilo/go-srcinfo v1.0.0
github.com/Morganamilo/go-srcinfo
# github.com/mikkeloscar/aur v0.0.0-20190912174111-183f80a38525
# github.com/mikkeloscar/aur v0.0.0-20200113170522-1cb4e2949656
github.com/mikkeloscar/aur