package module
Version: v1.0.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2021 License: GPL-3.0 Imports: 7 Imported by: 4




Fork of aur with the following differences:

  • Structured client
  • Custom http client support
  • Request editing


Client for simple AUR queries.


  • Search packages in the AUR by name only containing "python37"
aur-cli -verbose -by name search python37
  • Search packages in the AUR by name only containing "python37". Display results as JSON.
aur-cli -verbose -json -by name search python37
  • Find all packages in the AUR maintained by "jguer"
aur-cli -verbose -by maintainer search jguer
  • Retrieve information on the package "linux-git"
aur-cli info linux-git

go wrapper for the AUR JSON API

Wrapper around the json API v5 for AUR found at


This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see




This section is empty.


View Source
var ErrServiceUnavailable = errors.New("AUR is unavailable at this moment")

ErrServiceUnavailable represents a error when AUR is unavailable.


This section is empty.


type By

type By int

By specifies what to search by in RPC searches.

const (
	Name By = iota + 1

func (By) String

func (by By) String() string

type Client

type Client struct {
	BaseURL string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	HTTPClient HTTPRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn

Client for AUR searching and querying.

func NewClient

func NewClient(opts ...ClientOption) (*Client, error)

func (*Client) Info

func (c *Client) Info(ctx context.Context, pkgs []string, reqEditors ...RequestEditorFn) ([]Pkg, error)

Info shows info for one or multiple packages.

func (*Client) Search

func (c *Client) Search(ctx context.Context, query string, by By, reqEditors ...RequestEditorFn) ([]Pkg, error)

Search queries the AUR DB with an optional By field. Use By.None for default query param (name-desc).

type ClientInterface

type ClientInterface interface {
	// Search queries the AUR DB with an optional By filter.
	// Use By.None for default query param (name-desc)
	Search(ctx context.Context, query string, by By, reqEditors ...RequestEditorFn) ([]Pkg, error)

	// Info gives detailed information on existing package.
	Info(ctx context.Context, pkgs []string, reqEditors ...RequestEditorFn) ([]Pkg, error)

ClientInterface specification for the AUR client.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction.

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL allows overriding the default base URL of the client.

func WithHTTPClient

func WithHTTPClient(doer HTTPRequestDoer) ClientOption

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

func WithRequestEditorFn

func WithRequestEditorFn(fn RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

type HTTPRequestDoer

type HTTPRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)

HTTPRequestDoer performs HTTP requests. The standard http.Client implements this interface.

type PayloadError

type PayloadError struct {
	StatusCode int
	ErrorField string

func (*PayloadError) Error

func (r *PayloadError) Error() string

type Pkg

type Pkg struct {
	ID             int      `json:"ID"`
	Name           string   `json:"Name"`
	PackageBaseID  int      `json:"PackageBaseID"`
	PackageBase    string   `json:"PackageBase"`
	Version        string   `json:"Version"`
	Description    string   `json:"Description"`
	URL            string   `json:"URL"`
	NumVotes       int      `json:"NumVotes"`
	Popularity     float64  `json:"Popularity"`
	OutOfDate      int      `json:"OutOfDate"`
	Maintainer     string   `json:"Maintainer"`
	FirstSubmitted int      `json:"FirstSubmitted"`
	LastModified   int      `json:"LastModified"`
	URLPath        string   `json:"URLPath"`
	Depends        []string `json:"Depends"`
	MakeDepends    []string `json:"MakeDepends"`
	CheckDepends   []string `json:"CheckDepends"`
	Conflicts      []string `json:"Conflicts"`
	Provides       []string `json:"Provides"`
	Replaces       []string `json:"Replaces"`
	OptDepends     []string `json:"OptDepends"`
	Groups         []string `json:"Groups"`
	License        []string `json:"License"`
	Keywords       []string `json:"Keywords"`

Pkg holds package information.

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function.

Source Files


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL