nuget

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package nuget exposes nuget.org as a kit Domain.

A multi-domain host (ant) enables it with a single blank import:

import _ "github.com/tamnd/nuget-cli/nuget"

The same Domain also builds the standalone nuget binary.

Package nuget is the library behind the nuget command line: the HTTP client, request shaping, and the typed data models for NuGet.

The NuGet v3 API uses two separate base URLs: one for search (Azure Search) and one for package data (api.nuget.org). Both are configurable for testing. No API key is required for public read-only access.

Index

Constants

View Source
const DefaultUserAgent = "nuget-cli/0.1.0 (github.com/tamnd/nuget-cli)"

DefaultUserAgent identifies the client to NuGet.

View Source
const Host = "nuget.org"

Host is the primary nuget.org site hostname.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned when the API returns no results for a package lookup.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to NuGet over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) Info

func (c *Client) Info(ctx context.Context, name string) (Package, error)

Info returns the latest stable version info for a package by exact ID. It calls Search with the exact package ID and returns the first match.

func (*Client) Search

func (c *Client) Search(ctx context.Context, query string, prerelease bool, limit int) ([]Package, error)

Search finds NuGet packages matching query. prerelease includes pre-release versions when true. limit clips the returned slice; 0 uses default (10).

func (*Client) Versions

func (c *Client) Versions(ctx context.Context, name string) ([]PackageVersion, error)

Versions returns all versions of a package from the flat container index.

type Config

type Config struct {
	QueryURL  string // search endpoint base: https://azuresearch-usnc.nuget.org
	DataURL   string // package data base: https://api.nuget.org/v3
	UserAgent string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
}

Config holds all tunable parameters for the Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

type Domain

type Domain struct{}

Domain is the nuget driver.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify maps a package name or URL to (type, id).

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, hostnames, and binary identity.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate returns the nuget.org page URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and operations onto app.

type Package

type Package struct {
	ID          string   `json:"id"`
	Version     string   `json:"version"`
	Description string   `json:"description"`
	Authors     string   `json:"authors"`
	Downloads   int64    `json:"total_downloads"`
	Tags        []string `json:"tags"`
	URL         string   `json:"url"`
}

Package is one NuGet package record from the search endpoint.

type PackageVersion

type PackageVersion struct {
	Version string `json:"version"`
}

PackageVersion is one version string from the flat container index.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL