feat: 根据输入的参数,显示不同的内容

This commit is contained in:
liburdi 2024-10-22 13:52:33 +08:00
parent 0c35928eee
commit 265842feeb
2 changed files with 9 additions and 2 deletions

View File

@ -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

View File

@ -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)