go-internal: github.com/rogpeppe/go-internal/goproxytest Index | Files

package goproxytest

import "github.com/rogpeppe/go-internal/goproxytest"

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

Index

Package Files

allhex.go proxy.go pseudo.go

type Server Uses

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

func NewServer Uses

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 Uses

func (srv *Server) Close()

Close shuts down the proxy.

Package goproxytest imports 16 packages (graph) and is imported by 4 packages. Updated 2019-10-08. Refresh now. Tools for package owners.