From 9c26469d81a355b0c12b005ac9a6b4c25c62dfdb Mon Sep 17 00:00:00 2001 From: Alex Myasoedov Date: Wed, 1 Mar 2017 19:08:04 -0500 Subject: [PATCH] Accept port as a command line param --- main.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 9460784..3e506d3 100644 --- a/main.go +++ b/main.go @@ -163,6 +163,15 @@ func NewApp() *gin.Engine { func main() { r := NewApp() + port := "8080" + if len(os.Args) > 1 { + port = os.Args[1] + } else { + envPort := os.Getenv("PORT") + if len(envPort) > 0 { + port = envPort + } + } log.Info("Started http://0.0.0.0:8080") - r.Run(":8080") + r.Run(fmt.Sprintf(":%s", port)) }