From c2fb89eeb14bb710aac2c88cf16e3ce8aa468dee Mon Sep 17 00:00:00 2001 From: GrĂ©goire DuchĂȘne Date: Fri, 10 Apr 2020 00:23:26 +0100 Subject: Merge ADDR and PORT --- README.md | 12 ++++-------- cmd/gcp/main.go | 7 +++---- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 6c97d53..2b975db 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,9 @@ You need to set up the following environment variables for it to work: e.g. `golang.org/x/` for `golang.org/x/image`, and * `VCS` for the type of VCS you are using, e.g. `git`. -Additionally, the version under `gcp/` will use: - -* `ADDR` for the address to listen on, defaulting to every address, and -* `PORT` for the port to listen on, defaulting to 8080. - -See https://golang.org/pkg/net/#Dial for details of the address format. +Additionally, the version under `gcp/` will use `ADDR` for the address +to listen on, defaulting to every address on port 8080. See +https://golang.org/pkg/net/#Dial for details of the address format. If `ADDR` is set and starts with `/`, go-import-redirect will treat it -as the path of a UNIX socket to create and listen on. `PORT` is also -ignored. +as the path of a UNIX socket to create and listen on. diff --git a/cmd/gcp/main.go b/cmd/gcp/main.go index c284bbc..c726408 100644 --- a/cmd/gcp/main.go +++ b/cmd/gcp/main.go @@ -60,11 +60,10 @@ func main() { log.Fatalln("os.Chmod:", err) } } else { - port := os.Getenv("PORT") - if port == "" { - port = "8080" + if addr == "" { + addr = ":8080" } - if l, err = net.Listen("tcp", os.Getenv("ADDR")+":"+port); err != nil { + if l, err = net.Listen("tcp", addr); err != nil { log.Fatalln("net.Listen:", err) } } -- cgit v1.2.3-70-g09d2