forked from rogpeppe/go-internal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (41 loc) · 1.03 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2018 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.
// The txtar-goproxy command runs a Go module proxy from a txtar module
// directory (as manipulated by the txtar-addmod command).
//
// This allows interactive experimentation with the set of proxied modules.
// For example:
//
// cd cmd/go
// go test -proxy=localhost:1234 &
// export GOPROXY=http://localhost:1234/mod
//
// and then run go commands as usual.
package main
import (
"flag"
"fmt"
"log"
"os"
"github.com/gozelle/go-internal/goproxytest"
)
var proxyAddr = flag.String("addr", "", "run proxy on this network address")
func usage() {
fmt.Fprintf(os.Stderr, "usage: txtar-goproxy [flags] dir\n")
flag.PrintDefaults()
os.Exit(2)
}
func main() {
flag.Usage = usage
flag.Parse()
if flag.NArg() != 1 {
usage()
}
srv, err := goproxytest.NewServer(flag.Arg(0), *proxyAddr)
if err != nil {
log.Fatal(err)
}
fmt.Printf("export GOPROXY=%s\n", srv.URL)
select {}
}