...
Package goproxytest
import "github.com/rogpeppe/go-internal/goproxytest"
- Overview
- Index
Package goproxytest serves Go modules from a proxy server designed to run on
localhost during tests, both to make tests avoid requiring specific network
servers and also to make them significantly faster.
Each module archive is either a file named path_vers.txtar or path_vers.txt, or
a directory named path_vers, where slashes in path have been replaced with underscores.
The archive or directory must contain two files ".info" and ".mod", to be served as
the info and mod files in the proxy protocol (see
https://research.swtch.com/vgo-module). The remaining files are served as the
content of the module zip file. The path@vers prefix required of files in the
zip file is added automatically by the proxy: the files in the archive have
names without the prefix, like plain "go.mod", "x.go", and so on.
See ../cmd/txtar-addmod and ../cmd/txtar-c for tools generate txtar
files, although it's fine to write them by hand.
type Server struct {
URL string
}
func NewServer(dir, addr string) (*Server, error)
StartProxy starts the Go module proxy listening on the given
network address. It serves modules taken from the given directory
name. If addr is empty, it will listen on an arbitrary
localhost port. If dir is empty, "testmod" will be used.
The returned Server should be closed after use.
func (*Server) Close
¶
func (srv *Server) Close()
Close shuts down the proxy.