Debian Codegraph @

cmd/txtar-goproxy/main.go

raw symbols SCIP
1 // Copyright 2018 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // The txtar-goproxy command runs a Go module proxy from a txtar module
6 // directory (as manipulated by the txtar-addmod command).
7 //
8 // This allows interactive experimentation with the set of proxied modules.
9 // For example:
10 //
11 // cd cmd/go
12 // go test -proxy=localhost:1234 &
13 // export GOPROXY=http://localhost:1234/mod
14 //
15 // and then run go commands as usual.
16 package main
17
18 import (
19 "flag"
20 "fmt"
21 "log"
22 "os"
23
24 "github.com/rogpeppe/go-internal/goproxytest"
25 )
26
27 var proxyAddr = flag.String("addr", "", "run proxy on this network address")
28
29 func usage() {
30 fmt.Fprintf(os.Stderr, "usage: txtar-goproxy [flags] dir\n")
31 flag.PrintDefaults()
32 os.Exit(2)
33 }
34
35 func main() {
36 flag.Usage = usage
37 flag.Parse()
38 if flag.NArg() != 1 {
39 usage()
40 }
41 srv, err := goproxytest.NewServer(flag.Arg(0), *proxyAddr)
42 if err != nil {
43 log.Fatal(err)
44 }
45 fmt.Printf("export GOPROXY=%s\n", srv.URL)
46 select {}
47 }