Version: v1.10.0 Latest Latest

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

Go to latest
Published: Mar 27, 2023 License: BSD-3-Clause Imports: 16 Imported by: 0



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 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.



This section is empty.


This section is empty.


This section is empty.


type Server

type Server struct {
	URL string
	// contains filtered or unexported fields

func NewServer

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.

Jump to

Keyboard shortcuts

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