From 265842feebcf592fb243f52352a2cd5720f5323b Mon Sep 17 00:00:00 2001 From: liburdi Date: Tue, 22 Oct 2024 13:52:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A0=B9=E6=8D=AE=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E7=9A=84=E5=8F=82=E6=95=B0=EF=BC=8C=E6=98=BE=E7=A4=BA=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E7=9A=84=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- main.go | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index af32f777..d5987872 100644 --- a/Makefile +++ b/Makefile @@ -37,4 +37,4 @@ help: .PHONY: all build clean help local.run: - go mod vendor&& npm --prefix ./ui install && npm --prefix ./ui run build && go run main.go serve + go mod vendor&& npm --prefix ./ui install && npm --prefix ./ui run build && go run main.go serve --http 127.0.0.1:8090 diff --git a/main.go b/main.go index fa1d38d2..39758d42 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "log" "os" "strings" @@ -25,6 +26,12 @@ func main() { isGoRun := strings.HasPrefix(os.Args[0], os.TempDir()) + // 获取启动命令中的http参数 + var httpFlag string + flag.StringVar(&httpFlag, "http", "127.0.0.1:8090", "HTTP server address") + // "serve"影响解析 + _ = flag.CommandLine.Parse(os.Args[2:]) + migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{ // enable auto creation of migration files when making collection changes in the Admin UI // (the isGoRun check is to enable it only during development) @@ -48,7 +55,7 @@ func main() { }) defer log.Println("Exit!") - log.Println("Visit the website:", "http://127.0.0.1:8090") + log.Printf("Visit the website: http://%s", httpFlag) if err := app.Start(); err != nil { log.Fatal(err)