goredirect

package module
v0.0.0-...-78f25b0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2014 License: BSD-2-Clause Imports: 8 Imported by: 0

README

Package go-get-redirect

xrefs funcs top func

Package goredirect enables you to redirect go get to map from one set of repository URLs to another. You can use it to create a standalone server or wrap an existing one.

For a quick demo:

go install github.com/beyang/go-get-redirect/...
sudo sh -c 'echo "127.0.0.1 right.here" >> /etc/hosts'
sudo goredirect`
go get right.here/beyang/go-get-redirect

Observe that $GOPATH/src/right.here/beyang/go-get-redirect now holds identical contents to $GOPATH/src/github.com/beyang/go-get-redirect.

For usage examples, look at cmd/goredirect/cmd.go and the more extensive test cases in goredirect_test.go.

Notes

  • go get assumes all hostnames have at least one . in them, so go get localhost/repo/path will not work. In the dev environment, you can get around this by adding a dummy host (e.g., right.here) to /etc/hosts.

  • For development purposes, you can pass a custom port number with the --port flag, but go get assumes the server listens on port 80 (or 443 for HTTPS).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGoGetHandler

func NewGoGetHandler(mappings []Mapping, defaultHandler http.Handler) http.Handler

Types

type Mapping

type Mapping struct {
	DstVCS                 string
	DstScheme              string
	DstHostname            string
	SrcHostname            string // if empty, uses hostname in HTTP request
	SrcToDstRepoPathMapper *StringMapper
}

type StringMapper

type StringMapper struct {
	InputRegex     *regexp.Regexp
	OutputTemplate *template.Template
}

func MustGetNewStringMapper

func MustGetNewStringMapper(input string, output string) *StringMapper

func NewStringMapper

func NewStringMapper(input string, output string) (*StringMapper, error)

func (*StringMapper) MapString

func (m *StringMapper) MapString(str string) (string, error)

func (*StringMapper) MapStringPrefix

func (m *StringMapper) MapStringPrefix(str string) (mapped, matched, tail string, err error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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