move var Version to config package
This commit is contained in:
parent
eaacf04c68
commit
086dcad81f
2
build.sh
2
build.sh
|
@ -5,5 +5,5 @@ version=5.0.0-rc7-1
|
||||||
|
|
||||||
#export GO111MODULE=on
|
#export GO111MODULE=on
|
||||||
#export GOPROXY=https://goproxy.cn
|
#export GOPROXY=https://goproxy.cn
|
||||||
go build -ldflags "-X main.version=${version}" -o n9e-server main.go
|
go build -ldflags "-X github.com/didi/nightingale/v5/config.Version=${version}" -o n9e-server main.go
|
||||||
|
|
||||||
|
|
|
@ -2,3 +2,5 @@ package config
|
||||||
|
|
||||||
// Server周期性去数据库心跳,给自己起的名字
|
// Server周期性去数据库心跳,给自己起的名字
|
||||||
const EndpointName = "server_rpc"
|
const EndpointName = "server_rpc"
|
||||||
|
|
||||||
|
var Version = "not specified"
|
||||||
|
|
|
@ -37,6 +37,9 @@ func configRoutes(r *gin.Engine) {
|
||||||
guest.GET("/addr", func(c *gin.Context) {
|
guest.GET("/addr", func(c *gin.Context) {
|
||||||
c.String(200, c.Request.RemoteAddr)
|
c.String(200, c.Request.RemoteAddr)
|
||||||
})
|
})
|
||||||
|
guest.GET("/version", func(c *gin.Context) {
|
||||||
|
c.String(200, config.Version)
|
||||||
|
})
|
||||||
|
|
||||||
guest.POST("/auth/login", loginPost)
|
guest.POST("/auth/login", loginPost)
|
||||||
guest.GET("/auth/logout", logoutGet)
|
guest.GET("/auth/logout", logoutGet)
|
||||||
|
|
4
main.go
4
main.go
|
@ -26,8 +26,6 @@ import (
|
||||||
"github.com/didi/nightingale/v5/trans"
|
"github.com/didi/nightingale/v5/trans"
|
||||||
)
|
)
|
||||||
|
|
||||||
var version = "not specified"
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
vers *bool
|
vers *bool
|
||||||
help *bool
|
help *bool
|
||||||
|
@ -39,7 +37,7 @@ func init() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if *vers {
|
if *vers {
|
||||||
fmt.Println("version:", version)
|
fmt.Println("version:", config.Version)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue