diff --git a/outlet.go b/outlet.go index 5ecb52f..a5a566e 100644 --- a/outlet.go +++ b/outlet.go @@ -2,12 +2,12 @@ package main import ( "bufio" + "bytes" "fmt" "github.com/ddollar/forego/Godeps/_workspace/src/github.com/daviddengcn/go-colortext" "io" "os" "sync" - "bytes" ) type OutletFactory struct { diff --git a/start.go b/start.go index 8d07a0c..cc7cde2 100644 --- a/start.go +++ b/start.go @@ -104,6 +104,8 @@ func basePort(env Env) (int, error) { return flagPort, nil } else if env["PORT"] != "" { return strconv.Atoi(env["PORT"]) + } else if os.Getenv("PORT") != "" { + return strconv.Atoi(os.Getenv("PORT")) } return defaultPort, nil } diff --git a/start_test.go b/start_test.go index 666e680..df53b40 100644 --- a/start_test.go +++ b/start_test.go @@ -1,6 +1,9 @@ package main -import "testing" +import ( + "os" + "testing" +) func TestParseConcurrencyFlagEmpty(t *testing.T) { c, err := parseConcurrency("") @@ -117,6 +120,15 @@ func TestPortFromEnv(t *testing.T) { t.Fatal("Base port should be 5000") } + os.Setenv("PORT", "4000") + port, err = basePort(env) + if err != nil { + t.Fatal("Can not get port: %s", err) + } + if port != 4000 { + t.Fatal("Base port should be 4000") + } + env["PORT"] = "6000" port, err = basePort(env) if err != nil {