使用命令传递启动参数

This commit is contained in:
2024-11-14 11:12:57 +08:00
parent ca7ff275c6
commit 54092a0b9a
2 changed files with 6 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
@@ -217,7 +218,10 @@ func (image *Image) GetSimilarImagesIdList(collection_name string) (ids []int64)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU() - 1)
viper.SetConfigFile("./data/config.yaml")
configFilePath := flag.String("config", "./data/config.yaml", "配置文件路径")
flag.Parse()
viper.SetConfigFile(*configFilePath)
if err := viper.ReadInConfig(); err != nil {
log.Println("读取配置文件失败", err)
}