github.com/sirkon/goproxy@v1.4.8/module.go (about) 1 package goproxy 2 3 import ( 4 "context" 5 "io" 6 ) 7 8 // RevInfo describes a single revision of a module source 9 type RevInfo struct { 10 Version string // version string 11 Time string // commit time 12 13 // These fields are used for Stat of arbitrary rev, 14 // but they are not recorded when talking about module versions. 15 Name string `json:"-"` // complete ID in underlying repository 16 Short string `json:"-"` // shortened ID, for use in pseudo-version 17 } 18 19 // Module represents go module: some VSC (git, mercurial, svn, etc), Gitlab, another Go modules proxy, etc 20 type Module interface { 21 // ModulePath returns the module path. 22 ModulePath() string 23 24 // Versions lists all known versions with the given prefix. 25 // Pseudo-versions are not included. 26 // Versions should be returned sorted in semver order 27 // (implementations can use SortVersions). 28 Versions(ctx context.Context, prefix string) (tags []string, err error) 29 30 // Stat returns information about the revision rev. 31 // A revision can be any identifier known to the underlying service: 32 // commit hash, branch, tag, and so on. 33 Stat(ctx context.Context, rev string) (*RevInfo, error) 34 35 // GoMod returns the go.mod file for the given version. 36 GoMod(ctx context.Context, version string) (data []byte, err error) 37 38 // Zip returns file reader of ZIP file for the given version of the module 39 Zip(ctx context.Context, version string) (file io.ReadCloser, err error) 40 }