Skip to content

dakimura/gomodmrcli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

modpxycli

Build Status codecov Go Report Card GoDoc Join the chat at https://gitter.im/dakimura/gomodmrcli 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)
	}
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages