使用命令传递启动参数
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user