1
0
mirror of https://github.com/beego/bee.git synced 2024-11-21 18:40:54 +00:00

Merge pull request #824 from flycash/develop

fix Beego#4972: bee version failed
This commit is contained in:
Ming Deng 2022-06-10 19:04:27 +08:00 committed by GitHub
commit f9d0af2146
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 39 deletions

View File

@ -15,15 +15,15 @@ import (
// RuntimeInfo holds information about the current runtime. // RuntimeInfo holds information about the current runtime.
type RuntimeInfo struct { type RuntimeInfo struct {
GoVersion string GoVersion string
GOOS string GOOS string
GOARCH string GOARCH string
NumCPU int NumCPU int
GOPATH string GOPATH string
GOROOT string GOROOT string
Compiler string Compiler string
BeeVersion string BeeVersion string
Published string Published string
} }
// InitBanner loads the banner and prints it to output // InitBanner loads the banner and prints it to output
@ -52,7 +52,7 @@ func show(out io.Writer, content string) {
} }
err = t.Execute(out, RuntimeInfo{ err = t.Execute(out, RuntimeInfo{
GetGoVersion(), runtime.Version(),
runtime.GOOS, runtime.GOOS,
runtime.GOARCH, runtime.GOARCH,
runtime.NumCPU(), runtime.NumCPU(),

View File

@ -5,18 +5,14 @@ import (
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
"os"
"os/exec"
"runtime"
"strings"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"os"
"runtime"
"github.com/beego/bee/v2/cmd/commands" "github.com/beego/bee/v2/cmd/commands"
"github.com/beego/bee/v2/config" "github.com/beego/bee/v2/config"
beeLogger "github.com/beego/bee/v2/logger" beeLogger "github.com/beego/bee/v2/logger"
"github.com/beego/bee/v2/logger/colors" "github.com/beego/bee/v2/logger/colors"
"github.com/beego/bee/v2/utils"
) )
const verboseVersionBanner string = `%s%s______ const verboseVersionBanner string = `%s%s______
@ -33,7 +29,7 @@ const verboseVersionBanner string = `%s%s______
GOPATH : {{ .GOPATH }} GOPATH : {{ .GOPATH }}
GOROOT : {{ .GOROOT }} GOROOT : {{ .GOROOT }}
Compiler : {{ .Compiler }} Compiler : {{ .Compiler }}
Published : {{ .Published }}%s Date : {{ Now "Monday, 2 Jan 2006" }}%s
` `
const shortVersionBanner = `______ const shortVersionBanner = `______
@ -70,15 +66,14 @@ func versionCmd(cmd *commands.Command, args []string) int {
if outputFormat != "" { if outputFormat != "" {
runtimeInfo := RuntimeInfo{ runtimeInfo := RuntimeInfo{
GetGoVersion(), GoVersion: runtime.Version(),
runtime.GOOS, GOOS: runtime.GOOS,
runtime.GOARCH, GOARCH: runtime.GOARCH,
runtime.NumCPU(), NumCPU: runtime.NumCPU(),
os.Getenv("GOPATH"), GOPATH: os.Getenv("GOPATH"),
runtime.GOROOT(), GOROOT: runtime.GOROOT(),
runtime.Compiler, Compiler: runtime.Compiler,
version, BeeVersion: version,
utils.GetLastPublishedTime(),
} }
switch outputFormat { switch outputFormat {
case "json": case "json":
@ -113,15 +108,3 @@ func ShowShortVersionBanner() {
output := colors.NewColorWriter(os.Stdout) output := colors.NewColorWriter(os.Stdout)
InitBanner(output, bytes.NewBufferString(colors.MagentaBold(shortVersionBanner))) 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]
}

View File

@ -27,7 +27,7 @@ import (
const confVer = 0 const confVer = 0
const ( const (
Version = "2.0.2" Version = "2.0.3"
GitRemotePath = "github.com/beego/bee/v2" GitRemotePath = "github.com/beego/bee/v2"
) )

View File

@ -1252,6 +1252,7 @@ func parseStruct(imports []*ast.ImportSpec, st *ast.StructType, k string, m *swa
for name, p := range nm.Properties { for name, p := range nm.Properties {
m.Properties[name] = p m.Properties[name] = p
} }
m.Required = append(m.Required, nm.Required...)
continue continue
} }
} }