diff --git a/bin/main.go b/bin/main.go index 730765a..53dd719 100644 --- a/bin/main.go +++ b/bin/main.go @@ -17,6 +17,7 @@ import ( "git.satori.love/gameui/webp/models" _ "github.com/go-sql-driver/mysql" "github.com/milvus-io/milvus-sdk-go/v2/entity" + "github.com/spf13/viper" ) // string 转换为 int, 如果转换失败则返回默认值 @@ -362,6 +363,8 @@ func main() { w.Write(data) }) - log.Println("Server is running at http://localhost:6001") - http.ListenAndServe(":6001", nil) + // 从Viper中读取配置 + port := viper.GetString("server.port") + log.Println("Server is running at http://localhost:" + port) + http.ListenAndServe(":"+port, nil) }