gomodmrcli

package module
v0.0.0-...-d49b3f4 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: MIT Imports: 10 Imported by: 0

README

modpxycli

Build Status codecov Go Report Card GoDoc Sourcegraph Open Source Helpers Release TODOs

API client for https://index.golang.org/ and https://proxy.golang.org/

Installation

$ go get -u github.com/dakimura/gomodmrcli

and import in your code

import "github.com/dakimura/gomodmrcli"

Quick Start

package main

import (
	"fmt"
	"net/http"
	"time"

	"github.com/dakimura/gomodmrcli"
)

func main() {
	defaultHttpClient := new(http.Client)
	// --- e.g. get dependencies of the module
	modulePath := "google.golang.org/protobuf"
	moduleVersion := "v1.26.0"
	proxyCli := gomodmrcli.NewProxyClient(defaultHttpClient)
	mf, _ := proxyCli.Mod(modulePath, moduleVersion, false)

	fmt.Printf("%s@%s is depending on:\n", modulePath, moduleVersion)
	for _, req := range mf.Require {
		fmt.Println(req.Syntax.Token[0])
	}

	// --- e.g. get modules recently synchronized to the official go mod proxy
	indexCli := gomodmrcli.NewIndexClient(defaultHttpClient)
	indices, _ := indexCli.Index(time.Now().Add(-24*time.Hour), 5, false)

	fmt.Println()
	fmt.Println("Recently updated modules are:")
	for _, index := range indices {
		fmt.Println(index.Path)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

type Index struct {
	Path      string    `json:"Path"`
	Version   string    `json:"Version"`
	Timestamp time.Time `json:"Timestamp"`
}

type IndexClient

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

func NewIndexClient

func NewIndexClient(hc *http.Client) *IndexClient

func (*IndexClient) Index

func (c *IndexClient) Index(since time.Time, limit int, disableModuleFetch bool) ([]Index, error)

type ProxyClient

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

func NewProxyClient

func NewProxyClient(hc *http.Client) *ProxyClient

func (*ProxyClient) Mod

func (c *ProxyClient) Mod(modulePath string, version string, disableModuleFetch bool) (*modfile.File, error)

Jump to

Keyboard shortcuts

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