add version from flag
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
822c8038d2
commit
d9f7c16432
|
@ -17,6 +17,8 @@ func checkInput(token, message string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var Version = "No Version Provided"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
version := flag.Bool("v", false, "gorush version")
|
version := flag.Bool("v", false, "gorush version")
|
||||||
confPath := flag.String("c", "", "yaml configuration file path for gorush")
|
confPath := flag.String("c", "", "yaml configuration file path for gorush")
|
||||||
|
@ -32,6 +34,8 @@ func main() {
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
gorush.SetVersion(Version)
|
||||||
|
|
||||||
if *version {
|
if *version {
|
||||||
gorush.PrintGoRushVersion()
|
gorush.PrintGoRushVersion()
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
package gorush
|
package gorush
|
||||||
|
|
||||||
const (
|
|
||||||
// Version is gorush server version.
|
|
||||||
Version = "1.2.1"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// PlatFormIos constant is 1 for iOS
|
// PlatFormIos constant is 1 for iOS
|
||||||
PlatFormIos = iota + 1
|
PlatFormIos = iota + 1
|
||||||
|
|
|
@ -6,10 +6,16 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var version string
|
||||||
|
|
||||||
|
func SetVersion(ver string) {
|
||||||
|
version = ver
|
||||||
|
}
|
||||||
|
|
||||||
// PrintGoRushVersion provide print server engine
|
// PrintGoRushVersion provide print server engine
|
||||||
func PrintGoRushVersion() {
|
func PrintGoRushVersion() {
|
||||||
fmt.Printf(`GoRush %s, Compiler: %s %s, Copyright (C) 2016 Bo-Yi Wu, Inc.`,
|
fmt.Printf(`GoRush %s, Compiler: %s %s, Copyright (C) 2016 Bo-Yi Wu, Inc.`,
|
||||||
Version,
|
version,
|
||||||
runtime.Compiler,
|
runtime.Compiler,
|
||||||
runtime.Version())
|
runtime.Version())
|
||||||
}
|
}
|
||||||
|
@ -18,7 +24,7 @@ func PrintGoRushVersion() {
|
||||||
func VersionMiddleware() gin.HandlerFunc {
|
func VersionMiddleware() gin.HandlerFunc {
|
||||||
// Set out header value for each response
|
// Set out header value for each response
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
c.Writer.Header().Set("Server-Version", "GoRush/"+Version)
|
c.Writer.Header().Set("Server-Version", "GoRush/"+version)
|
||||||
c.Next()
|
c.Next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ for GOOS in $OS; do
|
||||||
(test "$GOOS" = "windows") && EXE="gorush.exe"
|
(test "$GOOS" = "windows") && EXE="gorush.exe"
|
||||||
|
|
||||||
echo "Build: ${GOOS}, Arch: ${GOARCH}, EXE: ${EXE}"
|
echo "Build: ${GOOS}, Arch: ${GOARCH}, EXE: ${EXE}"
|
||||||
GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="-s -w" -o bin/$GOOS/$GOARCH/${EXE} gorush.go;
|
GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="-s -w -X main.Version=${VERSION}" -o bin/$GOOS/$GOARCH/${EXE} gorush.go;
|
||||||
tar -C bin/$GOOS/$GOARCH -czf bin/gorush-$VERSION-$GOOS-$GOARCH.tar.gz gorush
|
tar -C bin/$GOOS/$GOARCH -czf bin/gorush-$VERSION-$GOOS-$GOARCH.tar.gz gorush
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue