Skip to content

Commit

Permalink
Merge pull request #827 from beego/develop
Browse files Browse the repository at this point in the history
Release v2.0.4
  • Loading branch information
flycash authored Jun 12, 2022
2 parents a75a0c8 + ef570ff commit 22ea0fa
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 83 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ ______
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v2.0.3
\____/ \___| \___| v2.0.4

├── Beego : 2.0.3
├── Beego : 2.0.4
├── GoVersion : go1.14.1
├── GOOS : darwin
├── GOARCH : amd64
Expand All @@ -90,8 +90,8 @@ $ bee version -o json
"GOPATH": "/home/beeuser/.go",
"GOROOT": "/usr/local/Cellar/go/1.14.1/libexec",
"Compiler": "gc",
"BeeVersion": "2.0.3",
"BeegoVersion": "2.0.3",
"BeeVersion": "2.0.4",
"BeegoVersion": "2.0.4",
"Published": "2020-09-13"
}
```
Expand Down
20 changes: 10 additions & 10 deletions cmd/commands/version/banner.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import (

// RuntimeInfo holds information about the current runtime.
type RuntimeInfo struct {
GoVersion string
GOOS string
GOARCH string
NumCPU int
GOPATH string
GOROOT string
Compiler string
BeeVersion string
Published string
GoVersion string
GOOS string
GOARCH string
NumCPU int
GOPATH string
GOROOT string
Compiler string
BeeVersion string
Published string
}

// InitBanner loads the banner and prints it to output
Expand Down Expand Up @@ -52,7 +52,7 @@ func show(out io.Writer, content string) {
}

err = t.Execute(out, RuntimeInfo{
GetGoVersion(),
runtime.Version(),
runtime.GOOS,
runtime.GOARCH,
runtime.NumCPU(),
Expand Down
73 changes: 8 additions & 65 deletions cmd/commands/version/version.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
package version

import (
"bufio"
"bytes"
"encoding/json"
"flag"
"fmt"
"gopkg.in/yaml.v2"
"io"
"os"
path "path/filepath"
"regexp"
"runtime"

"github.com/beego/bee/v2/cmd/commands"
"github.com/beego/bee/v2/config"
beeLogger "github.com/beego/bee/v2/logger"
"github.com/beego/bee/v2/logger/colors"
"github.com/beego/bee/v2/utils"
)

const verboseVersionBanner string = `%s%s______
Expand All @@ -27,7 +22,6 @@ const verboseVersionBanner string = `%s%s______
| |_/ /| __/| __/
\____/ \___| \___| v{{ .BeeVersion }}%s
%s%s
├── Beego : {{ .BeegoVersion }}
├── GoVersion : {{ .GoVersion }}
├── GOOS : {{ .GOOS }}
├── GOARCH : {{ .GOARCH }}
Expand Down Expand Up @@ -72,15 +66,14 @@ func versionCmd(cmd *commands.Command, args []string) int {

if outputFormat != "" {
runtimeInfo := RuntimeInfo{
GetGoVersion(),
runtime.GOOS,
runtime.GOARCH,
runtime.NumCPU(),
os.Getenv("GOPATH"),
runtime.GOROOT(),
runtime.Compiler,
version,
GetBeegoVersion(),
GoVersion: runtime.Version(),
GOOS: runtime.GOOS,
GOARCH: runtime.GOARCH,
NumCPU: runtime.NumCPU(),
GOPATH: os.Getenv("GOPATH"),
GOROOT: runtime.GOROOT(),
Compiler: runtime.Compiler,
BeeVersion: version,
}
switch outputFormat {
case "json":
Expand Down Expand Up @@ -115,53 +108,3 @@ func ShowShortVersionBanner() {
output := colors.NewColorWriter(os.Stdout)
InitBanner(output, bytes.NewBufferString(colors.MagentaBold(shortVersionBanner)))
}

func GetBeegoVersion() string {
re, err := regexp.Compile(`VERSION = "([0-9.]+)"`)
if err != nil {
return ""
}
wgopath := utils.GetGOPATHs()
if len(wgopath) == 0 {
beeLogger.Log.Error("GOPATH environment is empty,may be you use `go module`")
return ""
}
for _, wg := range wgopath {
wg, _ = path.EvalSymlinks(path.Join(wg, "src", "github.com", "astaxie", "beego"))
filename := path.Join(wg, "beego.go")
_, err := os.Stat(filename)
if err != nil {
if os.IsNotExist(err) {
continue
}
beeLogger.Log.Error("Error while getting stats of 'beego.go'")
}
fd, err := os.Open(filename)
if err != nil {
beeLogger.Log.Error("Error while reading 'beego.go'")
continue
}
reader := bufio.NewReader(fd)
for {
byteLine, _, er := reader.ReadLine()
if er != nil && er != io.EOF {
return ""
}
if er == io.EOF {
break
}
line := string(byteLine)
s := re.FindStringSubmatch(line)
if len(s) >= 2 {
return s[1]
}
}

}
return "Beego is not installed. Please do consider installing it first: https://github.com/beego/beego/v2. " +
"If you are using go mod, and you don't install the beego under $GOPATH/src/github.com/astaxie, just ignore this."
}

func GetGoVersion() string {
return runtime.Version()
}
2 changes: 1 addition & 1 deletion config/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
const confVer = 0

const (
Version = "2.0.2"
Version = "2.0.4"
GitRemotePath = "github.com/beego/bee/v2"
)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/beego/bee/v2
go 1.18

require (
github.com/beego/beego/v2 v2.0.3
github.com/beego/beego/v2 v2.0.4
github.com/davecgh/go-spew v1.1.1
github.com/flosch/pongo2 v0.0.0-20200529170236-5abacdfa4915
github.com/fsnotify/fsnotify v1.4.9
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk5
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/beego/beego/v2 v2.0.3 h1:vLrjDsn3JcxvIUqduDs4i0BdWuu5v7YN2FRKQcTWIDI=
github.com/beego/beego/v2 v2.0.3/go.mod h1:svcOCy6uDaGYHwcO3nppzKwFigeXm8WHkZfgnvemYNM=
github.com/beego/beego/v2 v2.0.4 h1:1NjpVkcqYVdKE06VJTQUVzsgZqFcaj0MqjHna57bWsA=
github.com/beego/beego/v2 v2.0.4/go.mod h1:21YTlo+jRYqrM/dLC0knzmo9C25x0pqddoKqy8kxev8=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down

0 comments on commit 22ea0fa

Please sign in to comment.