使用配置文件指定端口
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user