From 482d1d0291bf451a02be3285a358e85a9d6c3cdd Mon Sep 17 00:00:00 2001 From: cubercsl <2014cais01@gmail.com> Date: Wed, 11 Oct 2023 15:56:59 +0800 Subject: [PATCH] feat: allow changing the listening port (#70) Allow changing the listening port via command line or configuration file. Signed-off-by: cubercsl <2014cais01@gmail.com> --- cmd/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/main.go b/cmd/main.go index b966232..691b742 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -36,7 +36,7 @@ func main() { registerRoute(r) srv := &http.Server{ - Addr: ":8080", + Addr: viper.GetString("listen"), Handler: r, } @@ -64,6 +64,7 @@ func runServer(srv *http.Server) { func parseFlag() { pflag.StringP("configFile", "c", "config.yaml", "config file") + pflag.StringP("listen", "l", ":8080", "listen address") pflag.BoolP("version", "v", false, "version information") pflag.Parse() if err := viper.BindPFlags(pflag.CommandLine); err != nil {