mirror of
https://github.com/Jguer/yay
synced 2024-10-31 04:12:51 +00:00
Refactored AUR package
This commit is contained in:
parent
484eb3b75f
commit
a91984045c
3 changed files with 3 additions and 22 deletions
|
@ -13,6 +13,9 @@ import (
|
||||||
rpc "github.com/mikkeloscar/aur"
|
rpc "github.com/mikkeloscar/aur"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// BaseURL givers the AUR default address.
|
||||||
|
const BaseURL string = "https://aur.archlinux.org"
|
||||||
|
|
||||||
// NarrowSearch searches AUR and narrows based on subarguments
|
// NarrowSearch searches AUR and narrows based on subarguments
|
||||||
func NarrowSearch(pkgS []string, sortS bool) (Query, error) {
|
func NarrowSearch(pkgS []string, sortS bool) (Query, error) {
|
||||||
if len(pkgS) == 0 {
|
if len(pkgS) == 0 {
|
||||||
|
|
|
@ -7,8 +7,6 @@ import (
|
||||||
rpc "github.com/mikkeloscar/aur"
|
rpc "github.com/mikkeloscar/aur"
|
||||||
)
|
)
|
||||||
|
|
||||||
const aurURL = "https://aur.archlinux.org/rpc/?"
|
|
||||||
|
|
||||||
// Query is a collection of Results
|
// Query is a collection of Results
|
||||||
type Query []rpc.Pkg
|
type Query []rpc.Pkg
|
||||||
|
|
||||||
|
|
20
aur/utils.go
20
aur/utils.go
|
@ -1,20 +0,0 @@
|
||||||
package aur
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
// BaseURL givers the AUR default address.
|
|
||||||
const BaseURL string = "https://aur.archlinux.org"
|
|
||||||
|
|
||||||
// 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)
|
|
||||||
}
|
|
Loading…
Reference in a new issue