Skip to content

Commit

Permalink
Merge pull request #824 from flycash/develop
Browse files Browse the repository at this point in the history
fix Beego#4972: bee version failed
  • Loading branch information
flycash authored Jun 10, 2022
2 parents d7fcaf0 + afe1678 commit f9d0af2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 38 deletions.
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
37 changes: 10 additions & 27 deletions cmd/commands/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@ import (
"encoding/json"
"flag"
"fmt"
"gopkg.in/yaml.v2"
"os"
"os/exec"
"runtime"
"strings"

"gopkg.in/yaml.v2"

"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 @@ -33,7 +29,7 @@ const verboseVersionBanner string = `%s%s______
├── GOPATH : {{ .GOPATH }}
├── GOROOT : {{ .GOROOT }}
├── Compiler : {{ .Compiler }}
└── Published : {{ .Published }}%s
└── Date : {{ Now "Monday, 2 Jan 2006" }}%s
`

const shortVersionBanner = `______
Expand Down Expand Up @@ -70,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,
utils.GetLastPublishedTime(),
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 @@ -113,15 +108,3 @@ func ShowShortVersionBanner() {
output := colors.NewColorWriter(os.Stdout)
InitBanner(output, bytes.NewBufferString(colors.MagentaBold(shortVersionBanner)))
}

func GetGoVersion() string {
var (
cmdOut []byte
err error
)

if cmdOut, err = exec.Command("go", "version").Output(); err != nil {
beeLogger.Log.Fatalf("There was an error running 'go version' command: %s", err)
}
return strings.Split(string(cmdOut), " ")[2]
}
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.3"
GitRemotePath = "github.com/beego/bee/v2"
)

Expand Down
1 change: 1 addition & 0 deletions generate/swaggergen/g_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,7 @@ func parseStruct(imports []*ast.ImportSpec, st *ast.StructType, k string, m *swa
for name, p := range nm.Properties {
m.Properties[name] = p
}
m.Required = append(m.Required, nm.Required...)
continue
}
}
Expand Down

0 comments on commit f9d0af2

Please sign in to comment.