diff --git a/pkg/adapter/beego.go b/pkg/adapter/beego.go index efd2d4ea..eb7be3f6 100644 --- a/pkg/adapter/beego.go +++ b/pkg/adapter/beego.go @@ -15,12 +15,14 @@ package adapter import ( + "github.com/astaxie/beego/pkg" "github.com/astaxie/beego/pkg/server/web" ) const ( + // VERSION represent beego web framework version. - VERSION = web.VERSION + VERSION = pkg.VERSION // DEV is for develop DEV = web.DEV diff --git a/pkg/adapter/metric/prometheus.go b/pkg/adapter/metric/prometheus.go index 1d3488c6..6af2c26c 100644 --- a/pkg/adapter/metric/prometheus.go +++ b/pkg/adapter/metric/prometheus.go @@ -23,6 +23,7 @@ import ( "github.com/prometheus/client_golang/prometheus" + "github.com/astaxie/beego/pkg" "github.com/astaxie/beego/pkg/infrastructure/logs" "github.com/astaxie/beego/pkg/server/web" ) @@ -58,13 +59,13 @@ func registerBuildInfo() { Help: "The building information", ConstLabels: map[string]string{ "appname": web.BConfig.AppName, - "build_version": web.BuildVersion, - "build_revision": web.BuildGitRevision, - "build_status": web.BuildStatus, - "build_tag": web.BuildTag, - "build_time": strings.Replace(web.BuildTime, "--", " ", 1), - "go_version": web.GoVersion, - "git_branch": web.GitBranch, + "build_version": pkg.BuildVersion, + "build_revision": pkg.BuildGitRevision, + "build_status": pkg.BuildStatus, + "build_tag": pkg.BuildTag, + "build_time": strings.Replace(pkg.BuildTime, "--", " ", 1), + "go_version": pkg.GoVersion, + "git_branch": pkg.GitBranch, "start_time": time.Now().Format("2006-01-02 15:04:05"), }, }, []string{}) diff --git a/pkg/server/web/build_info.go b/pkg/build_info.go similarity index 88% rename from pkg/server/web/build_info.go rename to pkg/build_info.go index 53351c11..778856c6 100644 --- a/pkg/server/web/build_info.go +++ b/pkg/build_info.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package web +package pkg var ( BuildVersion string @@ -25,3 +25,8 @@ var ( GitBranch string ) + +const ( + // VERSION represent beego web framework version. + VERSION = "1.12.2" +) diff --git a/pkg/server/web/beego.go b/pkg/server/web/beego.go index 76e7b85e..42bfc8be 100644 --- a/pkg/server/web/beego.go +++ b/pkg/server/web/beego.go @@ -22,9 +22,6 @@ import ( ) const ( - // VERSION represent beego web framework version. - VERSION = "1.12.2" - // DEV is for develop DEV = "dev" // PROD is for production diff --git a/pkg/server/web/config.go b/pkg/server/web/config.go index 6e69a2fb..309f9b87 100644 --- a/pkg/server/web/config.go +++ b/pkg/server/web/config.go @@ -24,6 +24,7 @@ import ( "runtime" "strings" + "github.com/astaxie/beego/pkg" "github.com/astaxie/beego/pkg/infrastructure/config" "github.com/astaxie/beego/pkg/infrastructure/logs" "github.com/astaxie/beego/pkg/infrastructure/session" @@ -208,7 +209,7 @@ func newBConfig() *Config { AppName: "beego", RunMode: PROD, RouterCaseSensitive: true, - ServerName: "beegoServer:" + VERSION, + ServerName: "beegoServer:" + pkg.VERSION, RecoverPanic: true, RecoverFunc: recoverPanic, CopyRequestBody: false, diff --git a/pkg/server/web/error.go b/pkg/server/web/error.go index b62fb70d..69e7ff02 100644 --- a/pkg/server/web/error.go +++ b/pkg/server/web/error.go @@ -23,6 +23,7 @@ import ( "strconv" "strings" + "github.com/astaxie/beego/pkg" "github.com/astaxie/beego/pkg/infrastructure/utils" "github.com/astaxie/beego/pkg/server/web/context" @@ -91,7 +92,7 @@ func showErr(err interface{}, ctx *context.Context, stack string) { "RequestURL": ctx.Input.URI(), "RemoteAddr": ctx.Input.IP(), "Stack": stack, - "BeegoVersion": VERSION, + "BeegoVersion": pkg.VERSION, "GoVersion": runtime.Version(), } t.Execute(ctx.ResponseWriter, data) @@ -378,7 +379,7 @@ func responseError(rw http.ResponseWriter, r *http.Request, errCode int, errCont t, _ := template.New("beegoerrortemp").Parse(errtpl) data := M{ "Title": http.StatusText(errCode), - "BeegoVersion": VERSION, + "BeegoVersion": pkg.VERSION, "Content": template.HTML(errContent), } t.Execute(rw, data) diff --git a/pkg/server/web/filter/prometheus/filter.go b/pkg/server/web/filter/prometheus/filter.go index f4231c73..eb5b0b78 100644 --- a/pkg/server/web/filter/prometheus/filter.go +++ b/pkg/server/web/filter/prometheus/filter.go @@ -21,6 +21,7 @@ import ( "github.com/prometheus/client_golang/prometheus" + "github.com/astaxie/beego/pkg" "github.com/astaxie/beego/pkg/server/web" "github.com/astaxie/beego/pkg/server/web/context" ) @@ -63,13 +64,13 @@ func registerBuildInfo() { Help: "The building information", ConstLabels: map[string]string{ "appname": web.BConfig.AppName, - "build_version": web.BuildVersion, - "build_revision": web.BuildGitRevision, - "build_status": web.BuildStatus, - "build_tag": web.BuildTag, - "build_time": strings.Replace(web.BuildTime, "--", " ", 1), - "go_version": web.GoVersion, - "git_branch": web.GitBranch, + "build_version": pkg.BuildVersion, + "build_revision": pkg.BuildGitRevision, + "build_status": pkg.BuildStatus, + "build_tag": pkg.BuildTag, + "build_time": strings.Replace(pkg.BuildTime, "--", " ", 1), + "go_version": pkg.GoVersion, + "git_branch": pkg.GitBranch, "start_time": time.Now().Format("2006-01-02 15:04:05"), }, }, []string{})