gomodule

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: MIT Imports: 19 Imported by: 2

README

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNoGoProxy

func IsNoGoProxy(path string) (bool, error)

IsNoGoProxy 判断地址是否不使用 GoProxy

func ScanGoModFile added in v0.0.3

func ScanGoModFile(fromDir string, fn func(dir string, mod modfile.File) error) error

ScanGoModFile 查找 go.mod 文件

func ScanGoModFileParallel added in v0.0.3

func ScanGoModFileParallel(fromDir string, conc int, fn func(dir string, mod modfile.File) error) error

Types

type GoProxy

type GoProxy struct {
	Client HTTPClient
	Proxy  string
	Module string
}

GoProxy 通过 goproxy 获取 模块的信息,如版本列表,指定版本号的元信息、代码

https://go.dev/ref/mod#module-proxy

func (*GoProxy) Latest

func (m *GoProxy) Latest(ctx context.Context) (*Info, error)

Latest version

call $base/$module/@latest

func (*GoProxy) VersionFiles

func (m *GoProxy) VersionFiles(ctx context.Context, version string) ([]fs.DirEntry, error)

func (*GoProxy) VersionInfo

func (m *GoProxy) VersionInfo(ctx context.Context, version string) (*Info, error)

VersionInfo

call $base/$module/@v/$version.info

func (*GoProxy) VersionList

func (m *GoProxy) VersionList(ctx context.Context) ([]string, error)

VersionList 版本列表 call $base/$module/@v/list

func (*GoProxy) VersionMod

func (m *GoProxy) VersionMod(ctx context.Context, version string) ([]byte, error)

VersionMod go.mod content

call $base/$module/@v/$version.mod

func (*GoProxy) VersionZip

func (m *GoProxy) VersionZip(ctx context.Context, version string) (*zip.Reader, error)

VersionZip 返回原始的 zip 数据 $base/$module/@v/$version.zip

type HTTPClient

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

type Info

type Info struct {
	// Time commit time
	Time time.Time

	// Version
	Version string
}

func (*Info) String

func (in *Info) String() string

type Module

type Module interface {
	VersionList(ctx context.Context) ([]string, error)
	VersionInfo(ctx context.Context, version string) (*Info, error)
	VersionMod(ctx context.Context, version string) ([]byte, error)
	VersionFiles(ctx context.Context, version string) ([]fs.DirEntry, error)
	Latest(ctx context.Context) (*Info, error)
}

type Modules

type Modules []Module

func (*Modules) Append

func (ms *Modules) Append(items ...Module)

func (Modules) Latest

func (ms Modules) Latest(ctx context.Context) (*Info, error)

func (Modules) VersionFiles

func (ms Modules) VersionFiles(ctx context.Context, version string) ([]fs.DirEntry, error)

func (Modules) VersionInfo

func (ms Modules) VersionInfo(ctx context.Context, version string) (*Info, error)

func (Modules) VersionList

func (ms Modules) VersionList(ctx context.Context) ([]string, error)

func (Modules) VersionMod

func (ms Modules) VersionMod(ctx context.Context, version string) ([]byte, error)

Directories

Path Synopsis
_example

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳