diff options
| author | Zyad A. Ali <zyad.ali.me@gmail.com> | 2021-02-22 20:42:16 +0200 |
|---|---|---|
| committer | Julie Qiu <julie@golang.org> | 2021-02-22 22:23:01 +0000 |
| commit | 17279e72dc50bfefd7f40b87a76884c136a85dfd (patch) | |
| tree | ec8a073e6375fd627f4779b081a297f11551ed7e /cmd/pkgsite | |
| parent | e5e14467473c07a01a10a76e0ea2499d7f061d04 (diff) | |
| download | go-x-pkgsite-17279e72dc50bfefd7f40b87a76884c136a85dfd.tar.xz | |
cmd/pkgsite: remove -local flag
As local mode is now separate, -local flag is no longer needed. Remove
it and use command line arguments instead.
Change-Id: Ib4841f582eaf16068a8db163ac91cf1f15855b2e
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/295170
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
Trust: Jamal Carvalho <jamal@golang.org>
Diffstat (limited to 'cmd/pkgsite')
| -rw-r--r-- | cmd/pkgsite/main.go | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/cmd/pkgsite/main.go b/cmd/pkgsite/main.go index e89f669b..91c197bc 100644 --- a/cmd/pkgsite/main.go +++ b/cmd/pkgsite/main.go @@ -9,7 +9,7 @@ // web page. // Usage: // -// pkgsite [flag] +// pkgsite [flag] [path1,path2] # Load modules from paths to memory. // // The flags are: // @@ -17,15 +17,13 @@ // Assume that local modules' paths are relative to GOPATH/src // -http=:8080 // HTTP service address to listen for incoming requests on -// -local=path1,path2 -// Accepts a GOPATH-like collection of local paths for modules to load to memory package main import ( "context" "flag" "net/http" - "path/filepath" + "strings" "time" "github.com/google/safehtml/template" @@ -41,21 +39,21 @@ const defaultAddr = "localhost:8080" // default webserver address var ( _ = flag.String("static", "content/static", "path to folder containing static files served") - gopathMode = flag.Bool("gopath_mode", false, "assume that local modules' paths are relative to GOPATH/src, used only with -local") + gopathMode = flag.Bool("gopath_mode", false, "assume that local modules' paths are relative to GOPATH/src") httpAddr = flag.String("http", defaultAddr, "HTTP service address to listen for incoming requests on") - localPaths = flag.String("local", "", "run locally, accepts a GOPATH-like collection of local paths for modules to load to memory") ) func main() { flag.Parse() ctx := context.Background() - var dsg func(context.Context) internal.DataSource - if *localPaths == "" { - log.Fatalf(ctx, "-local is not set") + + paths := flag.Arg(0) + if paths == "" { + log.Fatalf(ctx, "no paths given") } lds := localdatasource.New() - dsg = func(context.Context) internal.DataSource { return lds } + dsg := func(context.Context) internal.DataSource { return lds } server, err := frontend.NewServer(frontend.ServerConfig{ DataSourceGetter: dsg, StaticPath: template.TrustedSourceFromFlag(flag.Lookup("static").Value), @@ -64,7 +62,7 @@ func main() { log.Fatalf(ctx, "frontend.NewServer: %v", err) } - load(ctx, lds, *localPaths) + load(ctx, lds, paths) router := dcensus.NewRouter(frontend.TagRoute) server.Install(router.Handle, nil, nil) @@ -76,7 +74,7 @@ func main() { // load loads local modules from pathList. func load(ctx context.Context, ds *localdatasource.DataSource, pathList string) { - paths := filepath.SplitList(pathList) + paths := strings.Split(pathList, ",") loaded := len(paths) for _, path := range paths { var err error |
