feat: add version output

This commit is contained in:
Zhiqiang Li
2023-04-04 14:48:33 +08:00
parent f64241aed7
commit 7351a8982d
3 changed files with 26 additions and 2 deletions

View File

@@ -2,6 +2,9 @@ package main
import (
"context"
"flag"
"fmt"
"github.com/stulzq/azure-openai-proxy/azure"
"log"
"net/http"
"os"
@@ -12,7 +15,16 @@ import (
"github.com/pkg/errors"
)
var (
version = ""
buildDate = ""
gitCommit = ""
)
func main() {
parseFlag()
azure.Init()
gin.SetMode(gin.ReleaseMode)
r := gin.Default()
registerRoute(r)
@@ -43,3 +55,14 @@ func runServer(srv *http.Server) {
}
log.Println("Server exiting")
}
func parseFlag() {
ver := flag.Bool("v", false, "version")
flag.Parse()
if *ver {
fmt.Println("version:", version)
fmt.Println("buildDate:", buildDate)
fmt.Println("gitCommit:", gitCommit)
os.Exit(0)
}
}