goproxy-host

command module
v0.0.0-...-e0461a9 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2020 License: MIT Imports: 18 Imported by: 0

README

GOPROXY CircleCI

A global proxy for go modules. see: https://goproxy.io

Requirements

It invokes the local go command to answer requests.
The default cacheDir is GOPATH, you can set it up by yourself according to the situation.

Build

git clone https://github.com/goproxyio/goproxy.git
cd goproxy
make

Started

Proxy mode
./bin/goproxy -listen=0.0.0.0:80 -cacheDir=/tmp/test

If you run `go get -v pkg` in the proxy machine, should set a new GOPATH which is different from the old GOPATH, or mayebe deadlock.
See the file test/get_test.sh.
Router mode

Use the -proxy flag switch to "Router mode", which implements route filter to routing private module or public module .

                                         direct
                      +----------------------------------> private repo
                      |
                 match|pattern
                      |
                  +---+---+           +----------+
go get  +-------> |goproxy| +-------> |goproxy.io| +---> golang.org/x/net
                  +-------+           +----------+
                 router mode           proxy mode

In Router mode, use the -exclude flag set pattern , direct to the repo which match the module path, pattern are matched to the full path specified, not only to the host component.

./bin/goproxy -listen=0.0.0.0:80 -cacheDir=/tmp/test -proxy https://goproxy.io -exclude "*.corp.example.com,rsc.io/private"

Use docker image

docker run -d -p80:8081 goproxy/goproxy

Use the -v flag to persisting the proxy module data (change cacheDir to your own dir):

docker run -d -p80:8081 -v cacheDir:/go goproxy/goproxy

Docker Compose

docker-compose up

Appendix

  1. set export GOPROXY=http://localhost to enable your goproxy.
  2. set export GOPROXY=direct to disable it.

Documentation

Overview

Copyright 2019 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. Usage:

goproxy [-listen [host]:port] [-cacheDir /tmp]

goproxy serves the Go module proxy HTTP protocol at the given address (default 0.0.0.0:8081). It invokes the local go command to answer requests and therefore reuses the current GOPATH's module download cache and configuration (GOPROXY, GOSUMDB, and so on).

While the proxy is running, setting GOPROXY=http://host:port will instruct the go command to use it. Note that the module proxy cannot share a GOPATH with its own clients or else fetches will deadlock. (The client will lock the entry as “being downloaded” before sending the request to the proxy, which will then wait for the apparently-in-progress download to finish.)

Directories

Path Synopsis
Package renameio writes files atomically by renaming temporary files.
Package renameio writes files atomically by renaming temporary files.
Package robustio wraps I/O functions that are prone to failure on Windows, transparently retrying errors up to an arbitrary timeout.
Package robustio wraps I/O functions that are prone to failure on Windows, transparently retrying errors up to an arbitrary timeout.

Jump to

Keyboard shortcuts

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